|
| 1 | +//===--- ConcurrencyUtils.h -----------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See https://swift.org/LICENSE.txt for license information |
| 9 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +#ifndef SWIFT_SILGEN_CONCURRENCYUTILS_H |
| 14 | +#define SWIFT_SILGEN_CONCURRENCYUTILS_H |
| 15 | + |
| 16 | +#include "RValue.h" |
| 17 | +#include "SILGenFunction.h" |
| 18 | + |
| 19 | +#include "swift/SIL/ConcurrencyUtils.h" |
| 20 | + |
| 21 | +namespace swift { |
| 22 | + |
| 23 | +class SILLocation; |
| 24 | +class Expr; |
| 25 | + |
| 26 | +namespace Lowering { |
| 27 | + |
| 28 | +class SILGenFunction; |
| 29 | +class RValue; |
| 30 | +class ManagedValue; |
| 31 | + |
| 32 | +inline ManagedValue |
| 33 | +clearImplicitIsolationActorBits(SILGenFunction &SGF, SILLocation loc, |
| 34 | + ManagedValue implicitIsolatedActor, |
| 35 | + SILType type = {}) { |
| 36 | + return ManagedValue::forBorrowedRValue(clearImplicitIsolationActorBits( |
| 37 | + SGF.B, loc, implicitIsolatedActor.getUnmanagedValue(), type)); |
| 38 | +} |
| 39 | + |
| 40 | +/// Clear the TBI bits if AArch64HasTBI is set. Otherwise clear the low tagged |
| 41 | +/// bits. |
| 42 | +/// |
| 43 | +/// \param expr - the expression which yielded this r-value; its type |
| 44 | +/// will become the substituted formal type of this r-value |
| 45 | +/// \param implicitIsolatedActor should be an Optional<any Actor>. |
| 46 | +inline RValue |
| 47 | +clearImplicitIsolationActorBits(SILGenFunction &SGF, Expr *expr, |
| 48 | + ManagedValue implicitIsolatedActor, |
| 49 | + SILType type = {}) { |
| 50 | + return RValue(SGF, expr, |
| 51 | + clearImplicitIsolationActorBits(SGF, SILLocation(expr), |
| 52 | + implicitIsolatedActor, type)); |
| 53 | +} |
| 54 | + |
| 55 | +inline ManagedValue |
| 56 | +setImplicitIsolationActorBits(SILGenFunction &SGF, SILLocation loc, |
| 57 | + ManagedValue implicitIsolatedActor) { |
| 58 | + return ManagedValue::forBorrowedRValue(setImplicitIsolationActorBits( |
| 59 | + SGF.B, loc, implicitIsolatedActor.getUnmanagedValue())); |
| 60 | +} |
| 61 | + |
| 62 | +inline RValue |
| 63 | +setImplicitIsolationActorBits(SILGenFunction &SGF, Expr *expr, |
| 64 | + ManagedValue implicitIsolatedActor) { |
| 65 | + return RValue(SGF, expr, |
| 66 | + setImplicitIsolationActorBits(SGF, SILLocation(expr), |
| 67 | + implicitIsolatedActor)); |
| 68 | +} |
| 69 | + |
| 70 | +} // namespace Lowering |
| 71 | + |
| 72 | +} // namespace swift |
| 73 | + |
| 74 | +#endif |
0 commit comments