File: keypaths_external.sil

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (58 lines) | stat: -rw-r--r-- 3,078 bytes parent folder | download
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>