MIR Parser: Report an error when a virtual register is redefined.
[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     successors:  [ '%bb.2.exit', '%bb.1.less' ]
48     liveins:     [ '%edi' ]
49     # CHECK:      %0 = COPY %edi
50     # CHECK-NEXT: %1 = SUB32ri8 %0, 10
51     instructions:
52       - '%0 = COPY %edi'
53       - '%1 = SUB32ri8 %0, 10, implicit-def %eflags'
54       - 'JG_1 %bb.2.exit, implicit %eflags'
55       - 'JMP_1 %bb.1.less'
56   - id:          1
57     name:        less
58     # CHECK:      %2 = MOV32r0
59     # CHECK-NEXT: %eax = COPY %2
60     instructions:
61       - '%2 = MOV32r0 implicit-def %eflags'
62       - '%eax = COPY %2'
63       - 'RETQ %eax'
64   - id:          2
65     name:        exit
66     instructions:
67       - '%eax = COPY %0'
68       - 'RETQ %eax'
69 ...
70 ---
71 name:            foo
72 isSSA:           true
73 tracksRegLiveness: true
74 # CHECK: name: foo
75 # CHECK:      registers:
76 # CHECK-NEXT:   - { id: 0, class: gr32 }
77 # CHECK-NEXT:   - { id: 1, class: gr32 }
78 # CHECK-NEXT:   - { id: 2, class: gr32 }
79 registers:
80   - { id: 2, class: gr32 }
81   - { id: 0, class: gr32 }
82   - { id: 10, class: gr32 }
83 body:
84   - id:          0
85     name:        entry
86     successors:  [ '%bb.2.exit', '%bb.1.less' ]
87     liveins:     [ '%edi' ]
88     # CHECK:      %0 = COPY %edi
89     # CHECK-NEXT: %1 = SUB32ri8 %0, 10
90     instructions:
91       - '%2 = COPY %edi'
92       - '%0 = SUB32ri8 %2, 10, implicit-def %eflags'
93       - 'JG_1 %bb.2.exit, implicit %eflags'
94       - 'JMP_1 %bb.1.less'
95   - id:          1
96     name:        less
97     # CHECK:      %2 = MOV32r0
98     # CHECK-NEXT: %eax = COPY %2
99     instructions:
100       - '%10 = MOV32r0 implicit-def %eflags'
101       - '%eax = COPY %10'
102       - 'RETQ %eax'
103   - id:          2
104     name:        exit
105     # CHECK: %eax = COPY %0
106     instructions:
107       - '%eax = COPY %2'
108       - 'RETQ %eax'
109 ...