@@ -1330,6 +1330,17 @@ class SILBuilder {
13301330 forwardingOwnershipKind));
13311331 }
13321332
1333+ // / Create an unchecked_value_cast when Ownership SSA is enabled and
1334+ // / unchecked_bitwise_cast otherwise.
1335+ // /
1336+ // / Intended to be used in utility code that needs to support both Ownership
1337+ // / SSA and non-Ownership SSA code.
1338+ SILValue emitUncheckedValueCast (SILLocation loc, SILValue op, SILType ty) {
1339+ if (hasOwnership ())
1340+ return createUncheckedValueCast (loc, op, ty);
1341+ return createUncheckedBitwiseCast (loc, op, ty);
1342+ }
1343+
13331344 RefToBridgeObjectInst *createRefToBridgeObject (SILLocation Loc, SILValue Ref,
13341345 SILValue Bits) {
13351346 return createRefToBridgeObject (Loc, Ref, Bits, Ref->getOwnershipKind ());
@@ -2334,6 +2345,19 @@ class SILBuilder {
23342345 getSILDebugLocation (Loc), Operand, Kind));
23352346 }
23362347
2348+ SILValue emitUncheckedOwnershipConversion (SILLocation Loc, SILValue Operand,
2349+ ValueOwnershipKind Kind) {
2350+ if (!hasOwnership ())
2351+ return Operand;
2352+ return createUncheckedOwnershipConversion (Loc, Operand, Kind);
2353+ }
2354+
2355+ ImplicitActorToOpaqueIsolationCastInst *
2356+ createImplicitActorToOpaqueIsolationCast (SILLocation Loc, SILValue Value) {
2357+ return insert (new (getModule ()) ImplicitActorToOpaqueIsolationCastInst (
2358+ getSILDebugLocation (Loc), Value));
2359+ }
2360+
23372361 FixLifetimeInst *createFixLifetime (SILLocation Loc, SILValue Operand) {
23382362 return insert (new (getModule ())
23392363 FixLifetimeInst (getSILDebugLocation (Loc), Operand));
@@ -2353,6 +2377,18 @@ class SILBuilder {
23532377 dependenceKind);
23542378 }
23552379
2380+ // / Emit a mark_dependence instruction placing the kind only if ownership is
2381+ // / set in the current function.
2382+ // /
2383+ // / This is intended to be used in code that is generic over Ownership SSA and
2384+ // / non-Ownership SSA code.
2385+ SILValue emitMarkDependence (SILLocation Loc, SILValue value, SILValue base,
2386+ MarkDependenceKind dependenceKind) {
2387+ return createMarkDependence (Loc, value, base, value->getOwnershipKind (),
2388+ hasOwnership () ? dependenceKind
2389+ : MarkDependenceKind::Escaping);
2390+ }
2391+
23562392 MarkDependenceInst *
23572393 createMarkDependence (SILLocation Loc, SILValue value, SILValue base,
23582394 ValueOwnershipKind forwardingOwnershipKind,
0 commit comments