MIR Serialization: Serialize the virtual register operands.
[oota-llvm.git] / test / CodeGen / MIR / X86 / virtual-registers.mir
1 # RUN: llc -march=x86-64 -start-after machine-sink -stop-after machine-sink -o /dev/null %s | FileCheck %s
2 # This test ensures that the MIR parser parses virtual register definitions and
3 # references correctly.
4
5 --- |
6
7   define i32 @bar(i32 %a) {
8   entry:
9     %0 = icmp sle i32 %a, 10
10     br i1 %0, label %less, label %exit
11
12   less:
13     ret i32 0
14
15   exit:
16     ret i32 %a
17   }
18
19   define i32 @foo(i32 %a) {
20   entry:
21     %0 = icmp sle i32 %a, 10
22     br i1 %0, label %less, label %exit
23
24   less:
25     ret i32 0
26
27   exit:
28     ret i32 %a
29   }
30
31 ...
32 ---
33 name:            bar
34 isSSA:           true
35 tracksRegLiveness: true
36 # CHECK:      registers:
37 # CHECK-NEXT:   - { id: 0, class: gr32 }
38 # CHECK-NEXT:   - { id: 1, class: gr32 }
39 # CHECK-NEXT:   - { id: 2, class: gr32 }
40 registers:
41   - { id: 0, class: gr32 }
42   - { id: 1, class: gr32 }
43   - { id: 2, class: gr32 }
44 body:
45   - id:          0
46     name:        entry
47     # CHECK:      %0 = COPY %edi
48     # CHECK-NEXT: %1 = SUB32ri8 %0, 10
49     instructions:
50       - '%0 = COPY %edi'
51       - '%1 = SUB32ri8 %0, 10, implicit-def %eflags'
52       - 'JG_1 %bb.2.exit, implicit %eflags'
53       - 'JMP_1 %bb.1.less'
54   - id:          1
55     name:        less
56     # CHECK:      %2 = MOV32r0
57     # CHECK-NEXT: %eax = COPY %2
58     instructions:
59       - '%2 = MOV32r0 implicit-def %eflags'
60       - '%eax = COPY %2'
61       - 'RETQ %eax'
62   - id:          2
63     name:        exit
64     instructions:
65       - '%eax = COPY %0'
66       - 'RETQ %eax'
67 ...
68 ---
69 name:            foo
70 isSSA:           true
71 tracksRegLiveness: true
72 # CHECK: name: foo
73 # CHECK:      registers:
74 # CHECK-NEXT:   - { id: 0, class: gr32 }
75 # CHECK-NEXT:   - { id: 1, class: gr32 }
76 # CHECK-NEXT:   - { id: 2, class: gr32 }
77 registers:
78   - { id: 2, class: gr32 }
79   - { id: 0, class: gr32 }
80   - { id: 10, class: gr32 }
81 body:
82   - id:          0
83     name:        entry
84     # CHECK:      %0 = COPY %edi
85     # CHECK-NEXT: %1 = SUB32ri8 %0, 10
86     instructions:
87       - '%2 = COPY %edi'
88       - '%0 = SUB32ri8 %2, 10, implicit-def %eflags'
89       - 'JG_1 %bb.2.exit, implicit %eflags'
90       - 'JMP_1 %bb.1.less'
91   - id:          1
92     name:        less
93     # CHECK:      %2 = MOV32r0
94     # CHECK-NEXT: %eax = COPY %2
95     instructions:
96       - '%10 = MOV32r0 implicit-def %eflags'
97       - '%eax = COPY %10'
98       - 'RETQ %eax'
99   - id:          2
100     name:        exit
101     # CHECK: %eax = COPY %0
102     instructions:
103       - '%eax = COPY %2'
104       - 'RETQ %eax'
105 ...