select.mir
10.1 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# RUN: llc -O0 -mtriple=aarch64-apple-ios -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=IOS
# RUN: llc -O0 -mtriple=aarch64-linux-gnu -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=LINUX-DEFAULT
# RUN: llc -O0 -mtriple=aarch64-linux-gnu -relocation-model=pic -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=LINUX-PIC
--- |
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
define void @frame_index() {
%ptr0 = alloca i64
ret void
}
define i8* @gep(i8* %in) { ret i8* undef }
define i8* @gep_no_constant(i8* %in) { ret i8* undef }
define i8* @gep_bad_imm(i8* %in) { ret i8* undef }
define i8* @ptr_mask(i8* %in) { ret i8* undef }
@var_local = global i8 0
define i8* @global_local() { ret i8* undef }
@var_got = external global i8
define i8* @global_got() { ret i8* undef }
define void @icmp() { ret void }
define void @fcmp() { ret void }
define void @phi() { ret void }
define void @select() { ret void }
...
---
# CHECK-LABEL: name: frame_index
name: frame_index
legalized: true
regBankSelected: true
# CHECK: registers:
# CHECK-NEXT: - { id: 0, class: gpr64sp, preferred-register: '' }
registers:
- { id: 0, class: gpr }
stack:
- { id: 0, name: ptr0, offset: 0, size: 8, alignment: 8 }
# CHECK: body:
# CHECK: %0:gpr64sp = ADDXri %stack.0.ptr0, 0, 0
body: |
bb.0:
%0(p0) = G_FRAME_INDEX %stack.0.ptr0
$x0 = COPY %0(p0)
...
---
# CHECK-LABEL: name: gep
name: gep
legalized: true
regBankSelected: true
registers:
- { id: 0, class: gpr }
- { id: 1, class: gpr }
- { id: 2, class: gpr }
# CHECK: body:
# CHECK: %2:gpr64sp = ADDXri %0, 42, 0
body: |
bb.0:
liveins: $x0
%0(p0) = COPY $x0
%1(s64) = G_CONSTANT i64 42
%2(p0) = G_PTR_ADD %0, %1(s64)
$x0 = COPY %2(p0)
...
---
# CHECK-LABEL: name: gep_no_constant
name: gep_no_constant
legalized: true
regBankSelected: true
registers:
- { id: 0, class: gpr }
- { id: 1, class: gpr }
- { id: 2, class: gpr }
# CHECK: body:
# CHECK: %0:gpr64 = COPY $x0
# CHECK: %1:gpr64 = COPY $x1
# CHECK: %2:gpr64 = ADDXrr %0, %1
body: |
bb.0:
liveins: $x0, $x1
%0(p0) = COPY $x0
%1(s64) = COPY $x1
%2(p0) = G_PTR_ADD %0, %1(s64)
$x0 = COPY %2(p0)
...
---
# CHECK-LABEL: name: gep_bad_imm
name: gep_bad_imm
legalized: true
regBankSelected: true
registers:
- { id: 0, class: gpr }
- { id: 1, class: gpr }
- { id: 2, class: gpr }
# CHECK: body:
# CHECK: %0:gpr64 = COPY $x0
# CHECK: %3:gpr32 = MOVi32imm 10000
# CHECK: %1:gpr64 = SUBREG_TO_REG 0, %3, %subreg.sub_32
# CHECK: %2:gpr64 = ADDXrr %0, %1
body: |
bb.0:
liveins: $x0, $x1
%0(p0) = COPY $x0
%1(s64) = G_CONSTANT i64 10000
%2(p0) = G_PTR_ADD %0, %1(s64)
$x0 = COPY %2(p0)
...
---
# CHECK-LABEL: name: ptr_mask
name: ptr_mask
legalized: true
regBankSelected: true
# CHECK: body:
# CHECK: %1:gpr64sp = ANDXri %0, 8060
body: |
bb.0:
liveins: $x0
%0:gpr(p0) = COPY $x0
%1:gpr(p0) = G_PTR_MASK %0, 3
$x0 = COPY %1(p0)
...
---
# Global defined in the same linkage unit so no GOT is needed
# CHECK-LABEL: name: global_local
name: global_local
legalized: true
regBankSelected: true
registers:
- { id: 0, class: gpr }
# CHECK: body:
# IOS: %0:gpr64 = MOVaddr target-flags(aarch64-page) @var_local, target-flags(aarch64-pageoff, aarch64-nc) @var_local
# LINUX-DEFAULT: %0:gpr64 = MOVaddr target-flags(aarch64-page) @var_local, target-flags(aarch64-pageoff, aarch64-nc) @var_local
# LINUX-PIC: %0:gpr64 = LOADgot target-flags(aarch64-got) @var_local
body: |
bb.0:
%0(p0) = G_GLOBAL_VALUE @var_local
$x0 = COPY %0(p0)
...
---
# CHECK-LABEL: name: global_got
name: global_got
legalized: true
regBankSelected: true
registers:
- { id: 0, class: gpr }
# CHECK: body:
# IOS: %0:gpr64 = LOADgot target-flags(aarch64-got) @var_got
# LINUX-DEFAULT: %0:gpr64 = MOVaddr target-flags(aarch64-page) @var_got, target-flags(aarch64-pageoff, aarch64-nc) @var_got
# LINUX-PIC: %0:gpr64 = LOADgot target-flags(aarch64-got) @var_got
body: |
bb.0:
%0(p0) = G_GLOBAL_VALUE @var_got
$x0 = COPY %0(p0)
...
---
# CHECK-LABEL: name: icmp
name: icmp
legalized: true
regBankSelected: true
# CHECK: registers:
# CHECK-NEXT: - { id: 0, class: gpr32, preferred-register: '' }
# CHECK-NEXT: - { id: 1, class: gpr32, preferred-register: '' }
# CHECK-NEXT: - { id: 2, class: gpr64, preferred-register: '' }
# CHECK-NEXT: - { id: 3, class: gpr32, preferred-register: '' }
# CHECK-NEXT: - { id: 4, class: gpr64, preferred-register: '' }
# CHECK-NEXT: - { id: 5, class: gpr32, preferred-register: '' }
registers:
- { id: 0, class: gpr }
- { id: 1, class: gpr }
- { id: 2, class: gpr }
- { id: 3, class: gpr }
- { id: 4, class: gpr }
- { id: 5, class: gpr }
- { id: 6, class: gpr }
- { id: 7, class: gpr }
- { id: 8, class: gpr }
- { id: 9, class: gpr }
- { id: 10, class: gpr }
- { id: 11, class: gpr }
# CHECK: body:
# CHECK: $wzr = SUBSWrr %0, %0, implicit-def $nzcv
# CHECK: %1:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
# CHECK: $xzr = SUBSXrr %2, %2, implicit-def $nzcv
# CHECK: %3:gpr32 = CSINCWr $wzr, $wzr, 3, implicit $nzcv
# CHECK: $xzr = SUBSXrr %4, %4, implicit-def $nzcv
# CHECK: %5:gpr32 = CSINCWr $wzr, $wzr, 0, implicit $nzcv
body: |
bb.0:
liveins: $w0, $x0
%0(s32) = COPY $w0
%1(s32) = G_ICMP intpred(eq), %0, %0
%6(s1) = G_TRUNC %1(s32)
%9(s32) = G_ANYEXT %6
$w0 = COPY %9(s32)
%2(s64) = COPY $x0
%3(s32) = G_ICMP intpred(uge), %2, %2
%7(s1) = G_TRUNC %3(s32)
%10(s32) = G_ANYEXT %7
$w0 = COPY %10(s32)
%4(p0) = COPY $x0
%5(s32) = G_ICMP intpred(ne), %4, %4
%8(s1) = G_TRUNC %5(s32)
%11(s32) = G_ANYEXT %8
$w0 = COPY %11(s32)
...
---
# CHECK-LABEL: name: fcmp
name: fcmp
legalized: true
regBankSelected: true
# CHECK: registers:
# CHECK-NEXT: - { id: 0, class: fpr32, preferred-register: '' }
# CHECK-NEXT: - { id: 1, class: gpr32, preferred-register: '' }
# CHECK-NEXT: - { id: 2, class: fpr64, preferred-register: '' }
# CHECK-NEXT: - { id: 3, class: gpr32, preferred-register: '' }
# CHECK-NEXT: - { id: 4, class: gpr32, preferred-register: '' }
# CHECK-NEXT: - { id: 5, class: gpr32, preferred-register: '' }
registers:
- { id: 0, class: fpr }
- { id: 1, class: gpr }
- { id: 2, class: fpr }
- { id: 3, class: gpr }
- { id: 4, class: gpr }
- { id: 5, class: gpr }
- { id: 6, class: gpr }
- { id: 7, class: gpr }
# CHECK: body:
# CHECK: FCMPSrr %0, %0, implicit-def $nzcv
# CHECK: [[TST_MI:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 5, implicit $nzcv
# CHECK: [[TST_GT:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 13, implicit $nzcv
# CHECK: %1:gpr32 = ORRWrr [[TST_MI]], [[TST_GT]]
# CHECK: FCMPDrr %2, %2, implicit-def $nzcv
# CHECK: %3:gpr32 = CSINCWr $wzr, $wzr, 4, implicit $nzcv
body: |
bb.0:
liveins: $w0, $x0
%0(s32) = COPY $s0
%1(s32) = G_FCMP floatpred(one), %0, %0
%4(s1) = G_TRUNC %1(s32)
%6(s32) = G_ANYEXT %4
$w0 = COPY %6(s32)
%2(s64) = COPY $d0
%3(s32) = G_FCMP floatpred(uge), %2, %2
%5(s1) = G_TRUNC %3(s32)
%7(s32) = G_ANYEXT %5
$w0 = COPY %7(s32)
...
---
# CHECK-LABEL: name: phi
name: phi
legalized: true
regBankSelected: true
tracksRegLiveness: true
# CHECK: registers:
# CHECK-NEXT: - { id: 0, class: fpr32, preferred-register: '' }
# CHECK-NEXT: - { id: 1, class: gpr32, preferred-register: '' }
# CHECK-NEXT: - { id: 2, class: fpr32, preferred-register: '' }
registers:
- { id: 0, class: fpr }
- { id: 1, class: gpr }
- { id: 2, class: fpr }
# CHECK: body:
# CHECK: bb.1:
# CHECK: %2:fpr32 = PHI %0, %bb.0, %2, %bb.1
body: |
bb.0:
liveins: $s0, $w0
successors: %bb.1
%0(s32) = COPY $s0
%3:gpr(s32) = COPY $w0
%1(s1) = G_TRUNC %3
bb.1:
successors: %bb.1, %bb.2
%2(s32) = PHI %0, %bb.0, %2, %bb.1
G_BRCOND %1, %bb.1
bb.2:
$s0 = COPY %2
RET_ReallyLR implicit $s0
...
---
# CHECK-LABEL: name: select
name: select
legalized: true
regBankSelected: true
tracksRegLiveness: true
# CHECK: registers:
# CHECK-NEXT: - { id: 0, class: gpr32, preferred-register: '' }
# CHECK-NEXT: - { id: 1, class: gpr32, preferred-register: '' }
# CHECK-NEXT: - { id: 2, class: gpr32, preferred-register: '' }
# CHECK-NEXT: - { id: 3, class: gpr32, preferred-register: '' }
# CHECK-NEXT: - { id: 4, class: gpr64, preferred-register: '' }
# CHECK-NEXT: - { id: 5, class: gpr64, preferred-register: '' }
# CHECK-NEXT: - { id: 6, class: gpr64, preferred-register: '' }
# CHECK-NEXT: - { id: 7, class: gpr64, preferred-register: '' }
# CHECK-NEXT: - { id: 8, class: gpr64, preferred-register: '' }
# CHECK-NEXT: - { id: 9, class: gpr64, preferred-register: '' }
registers:
- { id: 0, class: gpr }
- { id: 1, class: gpr }
- { id: 2, class: gpr }
- { id: 3, class: gpr }
- { id: 4, class: gpr }
- { id: 5, class: gpr }
- { id: 6, class: gpr }
- { id: 7, class: gpr }
- { id: 8, class: gpr }
- { id: 9, class: gpr }
# CHECK: body:
# CHECK: $wzr = ANDSWri %10, 0, implicit-def $nzcv
# CHECK: %3:gpr32 = CSELWr %1, %2, 1, implicit $nzcv
# CHECK: $wzr = ANDSWri %10, 0, implicit-def $nzcv
# CHECK: %6:gpr64 = CSELXr %4, %5, 1, implicit $nzcv
# CHECK: $wzr = ANDSWri %10, 0, implicit-def $nzcv
# CHECK: %9:gpr64 = CSELXr %7, %8, 1, implicit $nzcv
body: |
bb.0:
liveins: $w0, $w1, $w2
%10:gpr(s32) = COPY $w0
%0(s1) = G_TRUNC %10
%1(s32) = COPY $w1
%2(s32) = COPY $w2
%3(s32) = G_SELECT %0, %1, %2
$w0 = COPY %3(s32)
%4(s64) = COPY $x0
%5(s64) = COPY $x1
%6(s64) = G_SELECT %0, %4, %5
$x0 = COPY %6(s64)
%7(p0) = COPY $x0
%8(p0) = COPY $x1
%9(p0) = G_SELECT %0, %7, %8
$x0 = COPY %9(p0)
...