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
4 %type = type [4 x {i8, i32}]
6 define i8* @translate_element_size1(i64 %arg) {
7 ; CHECK-LABEL: name: translate_element_size1
8 ; CHECK: bb.1 (%ir-block.0):
10 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
11 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
12 ; CHECK: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[C]](s64)
13 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[INTTOPTR]], [[COPY]](s64)
14 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY [[GEP]](p0)
15 ; CHECK: $x0 = COPY [[COPY1]](p0)
16 ; CHECK: RET_ReallyLR implicit $x0
17 %tmp = getelementptr i8, i8* null, i64 %arg
21 define %type* @first_offset_const(%type* %addr) {
23 ; CHECK-LABEL: name: first_offset_const
24 ; CHECK: bb.1 (%ir-block.0):
26 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
27 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
28 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[C]](s64)
29 ; CHECK: $x0 = COPY [[GEP]](p0)
30 ; CHECK: RET_ReallyLR implicit $x0
31 %res = getelementptr %type, %type* %addr, i32 1
35 define %type* @first_offset_trivial(%type* %addr) {
37 ; CHECK-LABEL: name: first_offset_trivial
38 ; CHECK: bb.1 (%ir-block.0):
40 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
41 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY [[COPY]](p0)
42 ; CHECK: $x0 = COPY [[COPY1]](p0)
43 ; CHECK: RET_ReallyLR implicit $x0
44 %res = getelementptr %type, %type* %addr, i32 0
48 define %type* @first_offset_variable(%type* %addr, i64 %idx) {
50 ; CHECK-LABEL: name: first_offset_variable
51 ; CHECK: bb.1 (%ir-block.0):
52 ; CHECK: liveins: $x0, $x1
53 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
54 ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
55 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
56 ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C]], [[COPY1]]
57 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[MUL]](s64)
58 ; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY [[GEP]](p0)
59 ; CHECK: $x0 = COPY [[COPY2]](p0)
60 ; CHECK: RET_ReallyLR implicit $x0
61 %res = getelementptr %type, %type* %addr, i64 %idx
65 define %type* @first_offset_ext(%type* %addr, i32 %idx) {
67 ; CHECK-LABEL: name: first_offset_ext
68 ; CHECK: bb.1 (%ir-block.0):
69 ; CHECK: liveins: $w1, $x0
70 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
71 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
72 ; CHECK: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[COPY1]](s32)
73 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
74 ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C]], [[SEXT]]
75 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[MUL]](s64)
76 ; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY [[GEP]](p0)
77 ; CHECK: $x0 = COPY [[COPY2]](p0)
78 ; CHECK: RET_ReallyLR implicit $x0
79 %res = getelementptr %type, %type* %addr, i32 %idx
83 %type1 = type [4 x [4 x i32]]
84 define i32* @const_then_var(%type1* %addr, i64 %idx) {
86 ; CHECK-LABEL: name: const_then_var
87 ; CHECK: bb.1 (%ir-block.0):
88 ; CHECK: liveins: $x0, $x1
89 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
90 ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
91 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 272
92 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[C]](s64)
93 ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
94 ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C1]], [[COPY1]]
95 ; CHECK: [[GEP1:%[0-9]+]]:_(p0) = G_GEP [[GEP]], [[MUL]](s64)
96 ; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY [[GEP1]](p0)
97 ; CHECK: $x0 = COPY [[COPY2]](p0)
98 ; CHECK: RET_ReallyLR implicit $x0
99 %res = getelementptr %type1, %type1* %addr, i32 4, i32 1, i64 %idx
103 define i32* @var_then_const(%type1* %addr, i64 %idx) {
105 ; CHECK-LABEL: name: var_then_const
106 ; CHECK: bb.1 (%ir-block.0):
107 ; CHECK: liveins: $x0, $x1
108 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
109 ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
110 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 64
111 ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C]], [[COPY1]]
112 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[MUL]](s64)
113 ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 40
114 ; CHECK: [[GEP1:%[0-9]+]]:_(p0) = G_GEP [[GEP]], [[C1]](s64)
115 ; CHECK: $x0 = COPY [[GEP1]](p0)
116 ; CHECK: RET_ReallyLR implicit $x0
117 %res = getelementptr %type1, %type1* %addr, i64 %idx, i32 2, i32 2