File: keypaths_external.sil

package info (click to toggle)
swiftlang 6.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,532 kB
  • sloc: cpp: 9,901,743; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (58 lines) | stat: -rw-r--r-- 3,078 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -emit-module-path=%t/keypaths_external_other.swiftmodule -module-name=keypaths_external_other %S/Inputs/keypaths_external_other.swift
// -- Convert <i32 0x...> constants to decimal constants that LLVM will print
// RUN: %{python} %utils/chex.py < %s > %t/keypaths.sil
// RUN: %target-swift-frontend -module-name keypaths -emit-ir %s -I %t | %FileCheck %t/keypaths.sil

sil_stage canonical
import Swift
import keypaths_external_other

sil @generic_external : $@convention(thin) <A: Hashable, B: Hashable> (@in_guaranteed A, @in_guaranteed B, @in_guaranteed A, @in_guaranteed B, @in_guaranteed A, @in_guaranteed B) -> () {
entry(%0 : $*A, %1 : $*B, %2 : $*A, %3 : $*B, %4 : $*A, %5 : $*B):
  %t = keypath $KeyPath<G<B>, B>, <Z> (
    root $G<Z>;
    gettable_property $Z,
      id @g_x_get : $@convention(keypath_accessor_getter) <Z> (@in_guaranteed G<Z>) -> @out Z,
      getter @g_x_get : $@convention(keypath_accessor_getter) <Z> (@in_guaranteed G<Z>) -> @out Z,
      external #G.x<Z>
  ) <B>

  %u = keypath $KeyPath<G<A>, A>, <X: Hashable, Y: Hashable> (
    root $G<Y>;
    gettable_property $Y,
      id @g_subscript_get : $@convention(keypath_accessor_getter) <A: Hashable, B: Hashable> (@in_guaranteed G<B>, @in_guaranteed Int) -> @out B,
      getter @g_subscript_get : $@convention(keypath_accessor_getter) <A: Hashable, B: Hashable> (@in_guaranteed G<B>, @in_guaranteed Int) -> @out B,
      indices [%$0 : $X : $*X],
      indices_equals @s_equals : $@convention(keypath_accessor_equals) <A: Hashable, B: Hashable> (@in_guaranteed Int, @in_guaranteed Int) -> Bool,
      indices_hash @s_hash : $@convention(keypath_accessor_hash) <A: Hashable, B: Hashable> (@in_guaranteed Int) -> Int,
      external #G.subscript<Y, X>
  ) <B, A> (%1)

  strong_retain %t : $KeyPath<G<B>, B>
  strong_retain %u : $KeyPath<G<A>, A>

  return undef : $()
}

sil @g_x_get : $@convention(keypath_accessor_getter) <Z> (@in_guaranteed G<Z>) -> @out Z
sil @g_subscript_get : $@convention(keypath_accessor_getter) <A: Hashable, B: Hashable> (@in_guaranteed G<B>, @in_guaranteed Int) ->
@out B

sil @s_equals : $@convention(keypath_accessor_equals) <A: Hashable, B: Hashable> (@in_guaranteed Int, @in_guaranteed Int) -> Bool
sil @s_hash : $@convention(keypath_accessor_hash) <A: Hashable, B: Hashable> (@in_guaranteed Int) -> Int

// -- %t
// CHECK: [[KP_T:@keypath(\..*)?]] = private global <{ {{.*}} }> <{ {{.*}} i32 1, {{.*}} @"{{got.|\\01__imp__?}}$s23keypaths_external_other1GV1xxvpMV"
// CHECK-SAME:   @"symbolic x"
//            -- computed get-only property, identified by indirect pointer
// CHECK-SAME:   <i32 0x0208_0002>

// -- %u
// CHECK: [[KP_U:@keypath(\..*)?]] = private global <{ {{.*}} }> <{ {{.*}} i32 3, {{.*}} @"{{got.|\\01__imp__?}}$s23keypaths_external_other1GVyxqd__cSHRd__luipMV"
// CHECK-SAME:   @"symbolic q_"
// CHECK-SAME:   @"symbolic x"
// CHECK-SAME:   @"get_witness_table
//            -- computed get-only property, identified by indirect pointer
// CHECK-SAME:   <i32 0x0208_0002>