Files
swift-mirror/test/SIL/Parser/global_init_attribute.sil
Joe Groff 277608a69b Print and parse SILBoxTypes with a new syntax.
Use a syntax that declares the layout's generic parameters and fields,
followed by the generic arguments to apply to the layout:

  { var Int, let String } // A concrete box layout with a mutable Int
                          // and immutable String field
  <T, U> { var T, let U } <Int, String> // A generic box layout,
                                        // applied to Int and String
                                        // arguments
2016-12-02 13:44:22 -08:00

22 lines
691 B
Plaintext

// RUN: %target-swift-frontend -Xllvm -sil-full-demangle %s -emit-silgen | %FileCheck %s
sil_stage canonical
import Builtin
import Swift
// We cannot deserialize a SILDeclRef of kind GlobalAccessor, so this
// is not a proper addressor. But at least we can parse
// "[global_init]".
//
// CHECK-LABEL: g.MyVar.unsafeMutableAddressor : Swift.Int
// CHECK-NEXT: sil [global_init] @_TF1gau5MyVarSi
sil [global_init] @_TF1gau5MyVarSi : $@convention(thin) () -> Builtin.RawPointer {
bb0:
%b = alloc_box $<τ_0_0> { var τ_0_0 } <Int>
%ba = project_box %b : $<τ_0_0> { var τ_0_0 } <Int>, 0
%p = address_to_pointer %ba : $*Int to $Builtin.RawPointer
return %p : $Builtin.RawPointer
}