1 # RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
2 # This test ensures that the MIR parser parses the machine memory operands
7 define i32 @test(i32* %a) {
14 define void @test2(i32* %"a value") {
16 %b = load i32, i32* %"a value"
18 store i32 %c, i32* %"a value"
22 define void @test3(i32*) {
25 %b = load i32, i32* %0
31 define i32 @volatile_inc(i32* %x) {
33 %0 = load volatile i32, i32* %x
35 store volatile i32 %1, i32* %x
39 define void @non_temporal_store(i32* %a, i32 %b) {
41 store i32 %b, i32* %a, align 16, !nontemporal !0
47 define i32 @invariant_load(i32* %x) {
49 %v = load i32, i32* %x, !invariant.load !1
55 define void @memory_offset(<8 x float>* %vec) {
57 %v = load <8 x float>, <8 x float>* %vec
58 %v2 = insertelement <8 x float> %v, float 0.0, i32 4
59 store <8 x float> %v2, <8 x float>* %vec
63 define void @memory_alignment(<8 x float>* %vec) {
65 %v = load <8 x float>, <8 x float>* %vec
66 %v2 = insertelement <8 x float> %v, float 0.0, i32 4
67 store <8 x float> %v2, <8 x float>* %vec
71 define double @constant_pool_psv(double %a) {
73 %b = fadd double %a, 3.250000e+00
77 declare x86_fp80 @cosl(x86_fp80) #0
79 define x86_fp80 @stack_psv(x86_fp80 %x) {
81 %y = call x86_fp80 @cosl(x86_fp80 %x) #0
85 attributes #0 = { readonly }
87 @G = external global i32
89 define i32 @got_psv() {
91 %a = load i32, i32* @G
96 @0 = external global i32
98 define i32 @global_value() {
100 %a = load i32, i32* @G
102 %c = load i32, i32* @0
107 define i32 @jumptable_psv(i32 %in) {
109 switch i32 %in, label %def [
127 %struct.XXH_state64_t = type { i32, i32, i64, i64, i64 }
129 @a = common global i32 0, align 4
131 define i32 @tbaa_metadata() {
133 %0 = load i32, i32* @a, align 4, !tbaa !2
134 %1 = inttoptr i32 %0 to %struct.XXH_state64_t*
135 %total_len2 = bitcast %struct.XXH_state64_t* %1 to i32*
136 %2 = load i32, i32* %total_len2, align 4, !tbaa !6
140 !2 = !{!3, !3, i64 0}
141 !3 = !{!"int", !4, i64 0}
142 !4 = !{!"omnipotent char", !5, i64 0}
143 !5 = !{!"Simple C/C++ TBAA"}
144 !6 = !{!7, !3, i64 0}
145 !7 = !{!"XXH_state64_t", !3, i64 0, !3, i64 4, !8, i64 8, !8, i64 16, !8, i64 24}
146 !8 = !{!"long long", !4, i64 0}
148 define void @aa_scope(float* nocapture %a, float* nocapture readonly %c) #1 {
150 %0 = load float, float* %c, align 4, !alias.scope !9
151 %arrayidx.i = getelementptr inbounds float, float* %a, i64 5
152 store float %0, float* %arrayidx.i, align 4, !noalias !9
153 %1 = load float, float* %c, align 4
154 %arrayidx = getelementptr inbounds float, float* %a, i64 7
155 store float %1, float* %arrayidx, align 4
159 attributes #1 = { nounwind uwtable }
161 !9 = distinct !{!9, !10, !"some scope"}
162 !10 = distinct !{!10, !"some domain"}
164 define zeroext i1 @range_metadata(i8* %x) {
166 %0 = load i8, i8* %x, align 1, !range !11
167 %tobool = trunc i8 %0 to i1
173 %st = type { i32, i32 }
175 @values = common global [50 x %st] zeroinitializer, align 16
177 define void @gep_value(i64 %d) {
179 %conv = trunc i64 %d to i32
180 store i32 %conv, i32* getelementptr inbounds ([50 x %st], [50 x %st]* @values, i64 0, i64 0, i32 0), align 16
184 define i8* @undef_value() {
186 %0 = load i8*, i8** undef, align 8
190 define void @dummy0() { ret void }
191 define void @dummy1() { ret void }
192 define void @dummy2() { ret void }
193 define void @dummy3() { ret void }
197 tracksRegLiveness: true
203 ; CHECK: $eax = MOV32rm $rdi, 1, $noreg, 0, $noreg :: (load 4 from %ir.a)
204 ; CHECK-NEXT: MOV32mi killed $rdi, 1, $noreg, 0, $noreg, 42 :: (store 4 into %ir.a)
205 $eax = MOV32rm $rdi, 1, _, 0, _ :: (load 4 from %ir.a)
206 MOV32mi killed $rdi, 1, _, 0, _, 42 :: (store 4 into %ir.a)
211 tracksRegLiveness: true
217 ; CHECK: INC32m killed $rdi, 1, $noreg, 0, $noreg, implicit-def dead $eflags :: (store 4 into %ir."a value"), (load 4 from %ir."a value")
218 INC32m killed $rdi, 1, _, 0, _, implicit-def dead $eflags :: (store 4 into %ir."a value"), (load 4 from %ir."a value")
223 tracksRegLiveness: true
229 - { id: 0, offset: -12, size: 4, alignment: 4 }
233 ; Verify that the unnamed local values can be serialized.
234 ; CHECK-LABEL: name: test3
235 ; CHECK: $eax = MOV32rm killed $rdi, 1, $noreg, 0, $noreg :: (load 4 from %ir.0)
236 ; CHECK: MOV32mr $rsp, 1, $noreg, -4, $noreg, killed $eax :: (store 4 into %ir.1)
237 $eax = MOV32rm killed $rdi, 1, _, 0, _ :: (load 4 from %ir.0)
238 $eax = INC32r killed $eax, implicit-def dead $eflags
239 MOV32mr $rsp, 1, _, -4, _, killed $eax :: (store 4 into %ir.1)
244 tracksRegLiveness: true
250 ; CHECK: name: volatile_inc
251 ; CHECK: $eax = MOV32rm $rdi, 1, $noreg, 0, $noreg :: (volatile load 4 from %ir.x)
252 ; CHECK: MOV32mr killed $rdi, 1, $noreg, 0, $noreg, $eax :: (volatile store 4 into %ir.x)
253 $eax = MOV32rm $rdi, 1, _, 0, _ :: (volatile load 4 from %ir.x)
254 $eax = INC32r killed $eax, implicit-def dead $eflags
255 MOV32mr killed $rdi, 1, _, 0, _, $eax :: (volatile store 4 into %ir.x)
259 name: non_temporal_store
260 tracksRegLiveness: true
267 ; CHECK: name: non_temporal_store
268 ; CHECK: MOVNTImr killed $rdi, 1, $noreg, 0, $noreg, killed $esi :: (non-temporal store 4 into %ir.a)
269 MOVNTImr killed $rdi, 1, _, 0, _, killed $esi :: (non-temporal store 4 into %ir.a)
274 tracksRegLiveness: true
280 ; CHECK: name: invariant_load
281 ; CHECK: $eax = MOV32rm killed $rdi, 1, $noreg, 0, $noreg :: (invariant load 4 from %ir.x)
282 $eax = MOV32rm killed $rdi, 1, _, 0, _ :: (invariant load 4 from %ir.x)
287 tracksRegLiveness: true
293 ; CHECK: name: memory_offset
294 ; CHECK: $xmm0 = MOVAPSrm $rdi, 1, $noreg, 0, $noreg :: (load 16 from %ir.vec)
295 ; CHECK-NEXT: $xmm1 = MOVAPSrm $rdi, 1, $noreg, 16, $noreg :: (load 16 from %ir.vec + 16)
296 ; CHECK: MOVAPSmr $rdi, 1, $noreg, 0, $noreg, killed $xmm0 :: (store 16 into %ir.vec)
297 ; CHECK-NEXT: MOVAPSmr killed $rdi, 1, $noreg, 16, $noreg, killed $xmm1 :: (store 16 into %ir.vec + 16)
298 $xmm0 = MOVAPSrm $rdi, 1, _, 0, _ :: (load 16 from %ir.vec)
299 $xmm1 = MOVAPSrm $rdi, 1, _, 16, _ :: (load 16 from %ir.vec + 16)
301 $xmm1 = MOVSSrr killed $xmm1, killed $xmm2
302 MOVAPSmr $rdi, 1, _, 0, _, killed $xmm0 :: (store 16 into %ir.vec)
303 MOVAPSmr killed $rdi, 1, _, 16, _, killed $xmm1 :: (store 16 into %ir.vec + 16)
307 name: memory_alignment
308 tracksRegLiveness: true
314 ; CHECK: name: memory_alignment
315 ; CHECK: $xmm0 = MOVAPSrm $rdi, 1, $noreg, 0, $noreg :: (load 16 from %ir.vec, align 32)
316 ; CHECK-NEXT: $xmm1 = MOVAPSrm $rdi, 1, $noreg, 16, $noreg :: (load 16 from %ir.vec + 16, align 32)
317 ; CHECK: MOVAPSmr $rdi, 1, $noreg, 0, $noreg, killed $xmm0 :: (store 16 into %ir.vec, align 32)
318 ; CHECK-NEXT: MOVAPSmr killed $rdi, 1, $noreg, 16, $noreg, killed $xmm1 :: (store 16 into %ir.vec + 16, align 32)
319 $xmm0 = MOVAPSrm $rdi, 1, _, 0, _ :: (load 16 from %ir.vec, align 32)
320 $xmm1 = MOVAPSrm $rdi, 1, _, 16, _ :: (load 16 from %ir.vec + 16, align 32)
322 $xmm1 = MOVSSrr killed $xmm1, killed $xmm2
323 MOVAPSmr $rdi, 1, _, 0, _, killed $xmm0 :: (store 16 into %ir.vec, align 32)
324 MOVAPSmr killed $rdi, 1, _, 16, _, killed $xmm1 :: (store 16 into %ir.vec + 16, align 32)
328 name: constant_pool_psv
329 tracksRegLiveness: true
334 value: 'double 3.250000e+00'
338 ; CHECK: name: constant_pool_psv
339 ; CHECK: $xmm0 = ADDSDrm killed $xmm0, $rip, 1, $noreg, %const.0, $noreg :: (load 8 from constant-pool)
340 ; CHECK-NEXT: $xmm0 = ADDSDrm killed $xmm0, $rip, 1, $noreg, %const.0, $noreg :: (load 8 from constant-pool + 8)
341 $xmm0 = ADDSDrm killed $xmm0, $rip, 1, _, %const.0, _ :: (load 8 from constant-pool)
342 $xmm0 = ADDSDrm killed $xmm0, $rip, 1, _, %const.0, _ :: (load 8 from constant-pool + 8)
347 tracksRegLiveness: true
355 - { id: 0, offset: 0, size: 10, alignment: 16, isImmutable: true, isAliased: false }
358 $rsp = frame-setup SUB64ri8 $rsp, 24, implicit-def dead $eflags
359 CFI_INSTRUCTION def_cfa_offset 32
360 LD_F80m $rsp, 1, $noreg, 32, $noreg, implicit-def dead $fpsw, implicit $fpcw
361 ; CHECK: name: stack_psv
362 ; CHECK: ST_FP80m $rsp, 1, $noreg, 0, $noreg, implicit-def dead $fpsw, implicit $fpcw :: (store 10 into stack, align 16)
363 ST_FP80m $rsp, 1, _, 0, _, implicit-def dead $fpsw, implicit $fpcw :: (store 10 into stack, align 16)
364 CALL64pcrel32 &cosl, csr_64, implicit $rsp, implicit-def $rsp, implicit-def $fp0
365 $rsp = ADD64ri8 $rsp, 24, implicit-def dead $eflags
370 tracksRegLiveness: true
373 ; CHECK: name: got_psv
374 ; CHECK: $rax = MOV64rm $rip, 1, $noreg, @G, $noreg :: (load 8 from got)
375 $rax = MOV64rm $rip, 1, _, @G, _ :: (load 8 from got)
376 $eax = MOV32rm killed $rax, 1, _, 0, _
377 $eax = INC32r killed $eax, implicit-def dead $eflags
382 tracksRegLiveness: true
385 $rax = MOV64rm $rip, 1, _, @G, _
386 ; CHECK-LABEL: name: global_value
387 ; CHECK: $eax = MOV32rm killed $rax, 1, $noreg, 0, $noreg, implicit-def $rax :: (load 4 from @G)
388 ; CHECK: $ecx = MOV32rm killed $rcx, 1, $noreg, 0, $noreg, implicit-def $rcx :: (load 4 from @0)
389 $eax = MOV32rm killed $rax, 1, _, 0, _, implicit-def $rax :: (load 4 from @G)
390 $rcx = MOV64rm $rip, 1, _, @0, _
391 $ecx = MOV32rm killed $rcx, 1, _, 0, _, implicit-def $rcx :: (load 4 from @0)
392 $eax = LEA64_32r killed $rax, 1, killed $rcx, 1, _
397 tracksRegLiveness: true
401 kind: label-difference32
404 blocks: [ '%bb.3.lbl1', '%bb.4.lbl2', '%bb.5.lbl3', '%bb.6.lbl4' ]
407 successors: %bb.2.def, %bb.1.entry
410 $eax = MOV32rr $edi, implicit-def $rax
411 CMP32ri8 killed $edi, 3, implicit-def $eflags
412 JCC_1 %bb.2.def, 7, implicit killed $eflags
415 successors: %bb.3.lbl1, %bb.4.lbl2, %bb.5.lbl3, %bb.6.lbl4
418 $rcx = LEA64r $rip, 1, _, %jump-table.0, _
419 ; CHECK: name: jumptable_psv
420 ; CHECK: $rax = MOVSX64rm32 $rcx, 4, killed $rax, 0, $noreg :: (load 4 from jump-table, align 8)
421 $rax = MOVSX64rm32 $rcx, 4, killed $rax, 0, _ :: (load 4 from jump-table, align 8)
422 $rax = ADD64rr killed $rax, killed $rcx, implicit-def dead $eflags
426 $eax = MOV32r0 implicit-def dead $eflags
447 tracksRegLiveness: true
450 $rax = MOV64rm $rip, 1, _, @a, _ :: (load 8 from got)
451 ; CHECK-LABEL: name: tbaa_metadata
452 ; CHECK: $eax = MOV32rm killed $rax, 1, $noreg, 0, $noreg, implicit-def $rax :: (load 4 from @a, !tbaa !2)
453 ; CHECK-NEXT: $eax = MOV32rm killed $rax, 1, $noreg, 0, $noreg :: (load 4 from %ir.total_len2, !tbaa !6)
454 $eax = MOV32rm killed $rax, 1, _, 0, _, implicit-def $rax :: (load 4 from @a, !tbaa !2)
455 $eax = MOV32rm killed $rax, 1, _, 0, _ :: (load 4 from %ir.total_len2, !tbaa !6)
460 tracksRegLiveness: true
467 ; CHECK-LABEL: name: aa_scope
468 ; CHECK: $xmm0 = MOVSSrm_alt $rsi, 1, $noreg, 0, $noreg :: (load 4 from %ir.c, !alias.scope !9)
469 $xmm0 = MOVSSrm_alt $rsi, 1, _, 0, _ :: (load 4 from %ir.c, !alias.scope !9)
470 ; CHECK-NEXT: MOVSSmr $rdi, 1, $noreg, 20, $noreg, killed $xmm0 :: (store 4 into %ir.arrayidx.i, !noalias !9)
471 MOVSSmr $rdi, 1, _, 20, _, killed $xmm0 :: (store 4 into %ir.arrayidx.i, !noalias !9)
472 $xmm0 = MOVSSrm_alt killed $rsi, 1, _, 0, _ :: (load 4 from %ir.c)
473 MOVSSmr killed $rdi, 1, _, 28, _, killed $xmm0 :: (store 4 into %ir.arrayidx)
478 tracksRegLiveness: true
484 ; CHECK-LABEL: name: range_metadata
485 ; CHECK: $al = MOV8rm killed $rdi, 1, $noreg, 0, $noreg :: (load 1 from %ir.x, !range !11)
486 $al = MOV8rm killed $rdi, 1, _, 0, _ :: (load 1 from %ir.x, !range !11)
491 tracksRegLiveness: true
498 $rax = MOV64rm $rip, 1, _, @values, _ :: (load 8 from got)
499 ; CHECK-LABEL: gep_value
500 ; CHECK: MOV32mr killed $rax, 1, $noreg, 0, $noreg, $edi, implicit killed $rdi :: (store 4 into `i32* getelementptr inbounds ([50 x %st], [50 x %st]* @values, i64 0, i64 0, i32 0)`, align 16)
501 MOV32mr killed $rax, 1, _, 0, _, $edi, implicit killed $rdi :: (store 4 into `i32* getelementptr inbounds ([50 x %st], [50 x %st]* @values, i64 0, i64 0, i32 0)`, align 16)
506 tracksRegLiveness: true
509 ; CHECK-LABEL: name: undef_value
510 ; CHECK: $rax = MOV64rm undef $rax, 1, $noreg, 0, $noreg :: (load 8 from `i8** undef`)
511 $rax = MOV64rm undef $rax, 1, _, 0, _ :: (load 8 from `i8** undef`)
515 # Test memory operand without associated value.
516 # CHECK-LABEL: name: dummy0
517 # CHECK: $rax = MOV64rm undef $rax, 1, $noreg, 0, $noreg :: (load 8)
519 tracksRegLiveness: true
522 $rax = MOV64rm undef $rax, 1, _, 0, _ :: (load 8)
526 # Test parsing of stack references in machine memory operands.
527 # CHECK-LABEL: name: dummy1
528 # CHECK: $rax = MOV64rm $rsp, 1, $noreg, 0, $noreg :: (load 8 from %stack.0)
530 tracksRegLiveness: true
532 - { id: 0, size: 4, alignment: 4 }
535 $rax = MOV64rm $rsp, 1, _, 0, _ :: (load 8 from %stack.0)
539 # Test parsing of unknown size in machine memory operands without alignment.
540 # CHECK-LABEL: name: dummy2
541 # CHECK: $rax = MOV64rm $rsp, 1, $noreg, 0, $noreg :: (load unknown-size from %stack.0, align 1)
543 tracksRegLiveness: true
545 - { id: 0, size: 4, alignment: 4 }
548 $rax = MOV64rm $rsp, 1, _, 0, _ :: (load unknown-size from %stack.0)
552 # Test parsing of unknown size in machine memory operands with alignment.
553 # CHECK-LABEL: name: dummy3
554 # CHECK: $rax = MOV64rm $rsp, 1, $noreg, 0, $noreg :: (load unknown-size from %stack.0, align 4)
556 tracksRegLiveness: true
558 - { id: 0, size: 4, alignment: 4 }
561 $rax = MOV64rm $rsp, 1, _, 0, _ :: (load unknown-size from %stack.0, align 4)