File: accessbase_unit.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 (67 lines) | stat: -rw-r--r-- 3,075 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
59
60
61
62
63
64
65
66
67
// RUN: %target-sil-opt -test-runner %s -o /dev/null 2>&1 | %FileCheck %s

import Builtin

class Box<T> {
  var value: T
}

class C {}


// CHECK-LABEL: begin running test {{.*}} on test_phi_nested_access: get_access_base with
// CHECK:       sil @test_phi_nested_access : {{.*}} {
// CHECK:       bb0([[BOX:%[^,]+]] :
// CHECK:         [[VALUE_ADDR:%[^,]+]] = ref_element_addr [[BOX]]
// CHECK:         [[VALUE_ACCESS:%[^,]+]] = begin_access [read] [unsafe] [[VALUE_ADDR]]
// CHECK:         [[VALUE_PTR:%[^,]+]] = address_to_pointer [stack_protection] [[VALUE_ACCESS]]
// CHECK:         end_access [[VALUE_ACCESS]]
// CHECK:         br bb1([[VALUE_PTR]]
// CHECK:       bb1([[VALUE_PHI:%[^,]+]] :
// CHECK:       } // end sil function 'test_phi_nested_access'
// CHECK:       Address: [[VALUE_PHI]] = argument of bb1
// CHECK:       Base:   [[VALUE_ADDR]] = ref_element_addr
// CHECK-LABEL: end running test {{.*}} on test_phi_nested_access: get_access_base with
// CHECK-LABEL: begin running test {{.*}} on test_phi_nested_access: compute_access_storage with
// CHECK:       Address: [[VALUE_PHI]] = argument of bb1
// CHECK:       Class [[BOX]] = argument of bb0
// CHECK:         Field: var value: T Index: 0
// CHECK-LABEL: end running test {{.*}} on test_phi_nested_access: compute_access_storage with
// CHECK-LABEL: begin running test 3 of 3 on test_phi_nested_access: accesspath-base
// CHECK:       Access path base: %6 = argument of bb1
// CHECK:       Exact Use:   end_access %2
// CHECK-LABEL: end running test 3 of 3 on test_phi_nested_access: accesspath-base
sil @test_phi_nested_access : $@convention(method) (@guaranteed Box<C>) -> () {
bb1(%box : $Box<C>):         
  %value_addr = ref_element_addr %box : $Box<C>, #Box.value 
  %value_access = begin_access [read] [unsafe] %value_addr : $*C 
  %value_ptr = address_to_pointer [stack_protection] %value_access : $*C to $Builtin.RawPointer 
  end_access %value_access : $*C          
  br exit(%value_ptr : $Builtin.RawPointer)               

exit(%phi : $Builtin.RawPointer):                   
  specify_test "get_access_base @argument"
  specify_test "compute_access_storage @argument"
  specify_test "accesspath-base @argument"
  %retval = tuple ()
  return %retval : $()
} 

sil_global @global_c : $C

// CHECK-LABEL: begin running test {{.*}} on test_access_global
// CHECK:       sil @test_access_global : {{.*}} {
// CHECK:         [[GLOBAL:%[^,]+]] = global_addr @global_c
// CHECK:         [[ACCESS:%[^,]+]] = begin_access [read] [dynamic] [[GLOBAL]]
// CHECK:       } // end sil function 'test_access_global'
// CHECK:       Address:   [[ACCESS]] = begin_access [read] [dynamic] [[GLOBAL]]
// CHECK:       Access:   [[ACCESS]] = begin_access [read] [dynamic] [[GLOBAL]]
// CHECK-LABEL: end running test {{.*}} on test_access_global
sil @test_access_global : $@convention(thin) () -> () {
  %15 = global_addr @global_c : $*C
  specify_test "get_typed_access_address @instruction"
  %16 = begin_access [read] [dynamic] %15 : $*C
  end_access %16 : $*C
  %retval = tuple ()
  return %retval : $()
}