MIR Serialization: Serialize UsedPhysRegMask from the machine register info.
[oota-llvm.git] / test / CodeGen / MIR / X86 / used-physical-register-info.mir
1 # RUN: llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o /dev/null %s | FileCheck %s
2 # This test ensures that the MIR parser parses the callee saved register mask
3 # correctly and that the MIR parser can infer it as well.
4
5 --- |
6
7   define i32 @compute(i32 %a) #0 {
8   body:
9     %c = mul i32 %a, 11
10     ret i32 %c
11   }
12
13   define i32 @foo(i32 %a) #0 {
14   entry:
15     %b = call i32 @compute(i32 %a)
16     ret i32 %b
17   }
18
19   define i32 @bar(i32 %a) #0 {
20   entry:
21     %b = call i32 @compute(i32 %a)
22     ret i32 %b
23   }
24
25   define i32 @empty(i32 %a) #0 {
26   entry:
27     %b = call i32 @compute(i32 %a)
28     ret i32 %b
29   }
30
31   attributes #0 = { "no-frame-pointer-elim"="false" }
32
33 ...
34 ---
35 # CHECK: name: compute
36 # CHECK: liveins:
37 # CHECK-NEXT: - { reg: '%edi' }
38 # CHECK-NEXT: frameInfo:
39 name:            compute
40 liveins:
41   - { reg: '%edi' }
42 frameInfo:
43   stackSize:     8
44 body:
45   - id:          0
46     name:        body
47     liveins:     [ '%edi' ]
48     instructions:
49       - '%eax = IMUL32rri8 %edi, 11, implicit-def %eflags'
50       - 'RETQ %eax'
51 ...
52 ---
53 name:            foo
54 liveins:
55   - { reg: '%edi' }
56 # CHECK: name: foo
57 # CHECK: calleeSavedRegisters: [ '%bh', '%bl', '%bp', '%bpl', '%bx', '%ebp', '%ebx',
58 # CHECK-NEXT:                    '%rbp', '%rbx', '%r12', '%r13', '%r14', '%r15',
59 # CHECK-NEXT:                    '%r12b', '%r13b', '%r14b', '%r15b', '%r12d', '%r13d',
60 # CHECK-NEXT:                    '%r14d', '%r15d', '%r12w', '%r13w', '%r14w', '%r15w' ]
61 calleeSavedRegisters: [ '%bh', '%bl', '%bp', '%bpl', '%bx', '%ebp', '%ebx',
62                         '%rbp', '%rbx', '%r12', '%r13', '%r14', '%r15',
63                         '%r12b', '%r13b', '%r14b', '%r15b', '%r12d', '%r13d',
64                         '%r14d', '%r15d', '%r12w', '%r13w', '%r14w', '%r15w' ]
65 body:
66   - id:          0
67     name:        entry
68     liveins:     [ '%edi' ]
69     instructions:
70       - 'PUSH64r %rax, implicit-def %rsp, implicit %rsp'
71       - 'CALL64pcrel32 @compute, csr_64, implicit %rsp, implicit %edi, implicit-def %rsp, implicit-def %eax'
72       - '%rdx = POP64r implicit-def %rsp, implicit %rsp'
73       - 'RETQ %eax'
74 ...
75 ---
76 name:            bar
77 liveins:
78   - { reg: '%edi' }
79 # Verify that the callee saved register can be inferred from register mask
80 # machine operands:
81 # CHECK: name: bar
82 # CHECK: calleeSavedRegisters: [ '%bh', '%bl', '%bp', '%bpl', '%bx', '%ebp', '%ebx',
83 # CHECK-NEXT:                    '%rbp', '%rbx', '%r12', '%r13', '%r14', '%r15',
84 # CHECK-NEXT:                    '%r12b', '%r13b', '%r14b', '%r15b', '%r12d', '%r13d',
85 # CHECK-NEXT:                    '%r14d', '%r15d', '%r12w', '%r13w', '%r14w', '%r15w' ]
86 body:
87   - id:          0
88     name:        entry
89     liveins:     [ '%edi' ]
90     instructions:
91       - 'PUSH64r %rax, implicit-def %rsp, implicit %rsp'
92       - 'CALL64pcrel32 @compute, csr_64, implicit %rsp, implicit %edi, implicit-def %rsp, implicit-def %eax'
93       - '%rdx = POP64r implicit-def %rsp, implicit %rsp'
94       - 'RETQ %eax'
95 ...
96 ---
97 name:            empty
98 liveins:
99   - { reg: '%edi' }
100 # Verify that the callee saved register can be empty.
101 # CHECK: name: empty
102 # CHECK: calleeSavedRegisters: [ ]
103 calleeSavedRegisters: [ ]
104 body:
105   - id:          0
106     name:        entry
107     liveins:     [ '%edi' ]
108     instructions:
109       - 'PUSH64r %rax, implicit-def %rsp, implicit %rsp'
110       - 'CALL64pcrel32 @compute, csr_64, implicit %rsp, implicit %edi, implicit-def %rsp, implicit-def %eax'
111       - '%rdx = POP64r implicit-def %rsp, implicit %rsp'
112       - 'RETQ %eax'
113 ...