mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This instruction converts Builtin.ImplicitActor to Optional<any Actor>. In the process of doing so, it masks out the bits we may have stolen from the witness table pointer of Builtin.ImplicitActor. The bits that we mask out are the bottom two bits of the top nibble of the TBI space on platforms that support TBI (that is bit 60,61 on arm64). On platforms that do not support TBI, we just use the bottom two tagged pointer bits (0,1). By using an instruction, we avoid having to represent the bitmasking that we are performing at the SIL level and can instead just make the emission of the bitmasking an IRGen detail. It also allows us to move detection if we are compiling for AArch64 to be an IRGen flag instead of a LangOpts flag. The instruction is a guaranteed forwarding instruction since we want to treat its result as a borrowed projection from the Builtin.ImplicitActor.
25 lines
1.2 KiB
Plaintext
25 lines
1.2 KiB
Plaintext
// First parse this and then emit a *.sib. Then read in the *.sib, then recreate
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %target-sil-opt -sil-print-types %s -emit-sib -o %t/tmp.sib -module-name basic2
|
|
// RUN: %target-sil-opt -sil-print-types %t/tmp.sib -o - -module-name basic2 | %FileCheck %s
|
|
|
|
// TODO: We need to make it so that we do another trip through serialization. We
|
|
// cannot do this today since when we serialize sib into another sib file, we
|
|
// seem to lose the import of _Concurrency.
|
|
|
|
import Builtin
|
|
import Swift
|
|
import _Concurrency
|
|
|
|
// REQUIRES: concurrency
|
|
|
|
// CHECK-LABEL: sil [ossa] @test_cast_implicitactor_to_opaqueisolation : $@convention(thin) (@guaranteed Builtin.ImplicitActor) -> @owned Optional<any Actor> {
|
|
// CHECK: implicitactor_to_opaqueisolation_cast {{%.*}} : $Builtin.ImplicitActor
|
|
// CHECK: } // end sil function 'test_cast_implicitactor_to_opaqueisolation'
|
|
sil [ossa] @test_cast_implicitactor_to_opaqueisolation : $@convention(thin) (@guaranteed Builtin.ImplicitActor) -> @owned Optional<any Actor> {
|
|
bb0(%0 : @guaranteed $Builtin.ImplicitActor):
|
|
%1 = implicitactor_to_opaqueisolation_cast %0 : $Builtin.ImplicitActor
|
|
%2 = copy_value %1 : $Optional<any Actor>
|
|
return %2 : $Optional<any Actor>
|
|
}
|