• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2; RUN: llc -mtriple=aarch64-linux-gnu -O0 -global-isel -stop-after=irtranslator -o - %s | FileCheck %s
3
4%type = type [4 x {i8, i32}]
5
6define i8*  @translate_element_size1(i64 %arg) {
7; CHECK-LABEL: name: translate_element_size1
8; CHECK: [[OFFSET:%[0-9]+]]:_(s64) = COPY $x0
9; CHECK: [[ZERO:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
10; CHECK: [[BASE:%[0-9]+]]:_(p0) = G_INTTOPTR [[ZERO]]
11; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[BASE]], [[OFFSET]]
12  %tmp = getelementptr i8, i8* null, i64 %arg
13  ret i8* %tmp
14}
15
16define %type* @first_offset_const(%type* %addr) {
17
18  ; CHECK-LABEL: name: first_offset_const
19  ; CHECK: bb.1 (%ir-block.0):
20  ; CHECK:   liveins: $x0
21  ; CHECK:   [[COPY:%[0-9]+]]:_(p0) = COPY $x0
22  ; CHECK:   [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
23  ; CHECK:   [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[C]](s64)
24  ; CHECK:   $x0 = COPY [[GEP]](p0)
25  ; CHECK:   RET_ReallyLR implicit $x0
26  %res = getelementptr %type, %type* %addr, i32 1
27  ret %type* %res
28}
29
30define %type* @first_offset_trivial(%type* %addr) {
31
32  ; CHECK-LABEL: name: first_offset_trivial
33  ; CHECK: bb.1 (%ir-block.0):
34  ; CHECK:   liveins: $x0
35  ; CHECK:   [[COPY:%[0-9]+]]:_(p0) = COPY $x0
36  ; CHECK:   [[COPY1:%[0-9]+]]:_(p0) = COPY [[COPY]](p0)
37  ; CHECK:   $x0 = COPY [[COPY1]](p0)
38  ; CHECK:   RET_ReallyLR implicit $x0
39  %res = getelementptr %type, %type* %addr, i32 0
40  ret %type* %res
41}
42
43define %type* @first_offset_variable(%type* %addr, i64 %idx) {
44
45  ; CHECK-LABEL: name: first_offset_variable
46  ; CHECK: bb.1 (%ir-block.0):
47  ; CHECK:   liveins: $x0, $x1
48  ; CHECK:   [[COPY:%[0-9]+]]:_(p0) = COPY $x0
49  ; CHECK:   [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
50  ; CHECK:   [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
51  ; CHECK:   [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C]], [[COPY1]]
52  ; CHECK:   [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[MUL]](s64)
53  ; CHECK:   [[COPY2:%[0-9]+]]:_(p0) = COPY [[GEP]](p0)
54  ; CHECK:   $x0 = COPY [[COPY2]](p0)
55  ; CHECK:   RET_ReallyLR implicit $x0
56  %res = getelementptr %type, %type* %addr, i64 %idx
57  ret %type* %res
58}
59
60define %type* @first_offset_ext(%type* %addr, i32 %idx) {
61
62  ; CHECK-LABEL: name: first_offset_ext
63  ; CHECK: bb.1 (%ir-block.0):
64  ; CHECK:   liveins: $w1, $x0
65  ; CHECK:   [[COPY:%[0-9]+]]:_(p0) = COPY $x0
66  ; CHECK:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
67  ; CHECK:   [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
68  ; CHECK:   [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[COPY1]](s32)
69  ; CHECK:   [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C]], [[SEXT]]
70  ; CHECK:   [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[MUL]](s64)
71  ; CHECK:   [[COPY2:%[0-9]+]]:_(p0) = COPY [[GEP]](p0)
72  ; CHECK:   $x0 = COPY [[COPY2]](p0)
73  ; CHECK:   RET_ReallyLR implicit $x0
74  %res = getelementptr %type, %type* %addr, i32 %idx
75  ret %type* %res
76}
77
78%type1 = type [4 x [4 x i32]]
79define i32* @const_then_var(%type1* %addr, i64 %idx) {
80
81  ; CHECK-LABEL: name: const_then_var
82  ; CHECK: bb.1 (%ir-block.0):
83  ; CHECK:   liveins: $x0, $x1
84  ; CHECK:   [[COPY:%[0-9]+]]:_(p0) = COPY $x0
85  ; CHECK:   [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
86  ; CHECK:   [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 272
87  ; CHECK:   [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
88  ; CHECK:   [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[C]](s64)
89  ; CHECK:   [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C1]], [[COPY1]]
90  ; CHECK:   [[GEP1:%[0-9]+]]:_(p0) = G_GEP [[GEP]], [[MUL]](s64)
91  ; CHECK:   [[COPY2:%[0-9]+]]:_(p0) = COPY [[GEP1]](p0)
92  ; CHECK:   $x0 = COPY [[COPY2]](p0)
93  ; CHECK:   RET_ReallyLR implicit $x0
94  %res = getelementptr %type1, %type1* %addr, i32 4, i32 1, i64 %idx
95  ret i32* %res
96}
97
98define i32* @var_then_const(%type1* %addr, i64 %idx) {
99
100  ; CHECK-LABEL: name: var_then_const
101  ; CHECK: bb.1 (%ir-block.0):
102  ; CHECK:   liveins: $x0, $x1
103  ; CHECK:   [[COPY:%[0-9]+]]:_(p0) = COPY $x0
104  ; CHECK:   [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
105  ; CHECK:   [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 64
106  ; CHECK:   [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 40
107  ; CHECK:   [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C]], [[COPY1]]
108  ; CHECK:   [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[MUL]](s64)
109  ; CHECK:   [[GEP1:%[0-9]+]]:_(p0) = G_GEP [[GEP]], [[C1]](s64)
110  ; CHECK:   $x0 = COPY [[GEP1]](p0)
111  ; CHECK:   RET_ReallyLR implicit $x0
112  %res = getelementptr %type1, %type1* %addr, i64 %idx, i32 2, i32 2
113  ret i32* %res
114}
115