llvm-project/llvm/test/CodeGen/MIR/X86/memory-operands.mir

126 lines
3.2 KiB
Plaintext
Raw Normal View History

# RUN: llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o /dev/null %s | FileCheck %s
# This test ensures that the MIR parser parses the machine memory operands
# correctly.
--- |
define i32 @test(i32* %a) {
entry:
%b = load i32, i32* %a
store i32 42, i32* %a
ret i32 %b
}
define void @test2(i32* %"a value") {
entry2:
%b = load i32, i32* %"a value"
%c = add i32 %b, 1
store i32 %c, i32* %"a value"
ret void
}
define i32 @volatile_inc(i32* %x) {
entry:
%0 = load volatile i32, i32* %x
%1 = add i32 %0, 1
store volatile i32 %1, i32* %x
ret i32 %1
}
define void @non_temporal_store(i32* %a, i32 %b) {
entry:
store i32 %b, i32* %a, align 16, !nontemporal !0
ret void
}
!0 = !{i32 1}
define i32 @invariant_load(i32* %x) {
entry:
%v = load i32, i32* %x, !invariant.load !1
ret i32 %v
}
!1 = !{}
...
---
name: test
tracksRegLiveness: true
liveins:
- { reg: '%rdi' }
body:
- id: 0
name: entry
liveins: [ '%rdi' ]
instructions:
# CHECK: %eax = MOV32rm %rdi, 1, _, 0, _ :: (load 4 from %ir.a)
# CHECK-NEXT: MOV32mi killed %rdi, 1, _, 0, _, 42 :: (store 4 into %ir.a)
- '%eax = MOV32rm %rdi, 1, _, 0, _ :: (load 4 from %ir.a)'
- 'MOV32mi killed %rdi, 1, _, 0, _, 42 :: (store 4 into %ir.a)'
- 'RETQ %eax'
...
---
name: test2
tracksRegLiveness: true
liveins:
- { reg: '%rdi' }
body:
- id: 0
name: entry2
liveins: [ '%rdi' ]
instructions:
# CHECK: INC32m killed %rdi, 1, _, 0, _, implicit-def dead %eflags :: (store 4 into %ir."a value"), (load 4 from %ir."a value")
- 'INC32m killed %rdi, 1, _, 0, _, implicit-def dead %eflags :: (store 4 into %ir."a value"), (load 4 from %ir."a value")'
- RETQ
...
---
name: volatile_inc
tracksRegLiveness: true
liveins:
- { reg: '%rdi' }
body:
- id: 0
name: entry
liveins: [ '%rdi' ]
instructions:
# CHECK: name: volatile_inc
# CHECK: %eax = MOV32rm %rdi, 1, _, 0, _ :: (volatile load 4 from %ir.x)
# CHECK: MOV32mr killed %rdi, 1, _, 0, _, %eax :: (volatile store 4 into %ir.x)
- '%eax = MOV32rm %rdi, 1, _, 0, _ :: (volatile load 4 from %ir.x)'
- '%eax = INC32r killed %eax, implicit-def dead %eflags'
- 'MOV32mr killed %rdi, 1, _, 0, _, %eax :: (volatile store 4 into %ir.x)'
- 'RETQ %eax'
...
---
name: non_temporal_store
tracksRegLiveness: true
liveins:
- { reg: '%rdi' }
- { reg: '%esi' }
body:
- id: 0
name: entry
liveins: [ '%esi', '%rdi' ]
instructions:
# CHECK: name: non_temporal_store
# CHECK: MOVNTImr killed %rdi, 1, _, 0, _, killed %esi :: (non-temporal store 4 into %ir.a)
- 'MOVNTImr killed %rdi, 1, _, 0, _, killed %esi :: (non-temporal store 4 into %ir.a)'
- RETQ
...
---
name: invariant_load
tracksRegLiveness: true
liveins:
- { reg: '%rdi' }
body:
- id: 0
name: entry
liveins: [ '%rdi' ]
instructions:
# CHECK: name: invariant_load
# CHECK: %eax = MOV32rm killed %rdi, 1, _, 0, _ :: (invariant load 4 from %ir.x)
- '%eax = MOV32rm killed %rdi, 1, _, 0, _ :: (invariant load 4 from %ir.x)'
- 'RETQ %eax'
...