[DAGCombiner] Add target hook function to decide folding (mul (add x, c1), c2)
[llvm-project.git] / llvm / test / MC / Sparc / sparc-synthetic-instructions.s
blobf83c8c2893acdaabfef71092e78b45ac7f3de74b
1 ! RUN: llvm-mc %s -arch=sparc -show-encoding | FileCheck %s
2 ! RUN: llvm-mc %s -arch=sparcv9 -show-encoding | FileCheck %s
4 ! Section A.3 Synthetic Instructions
5 ! CHECK: cmp %g1, %g2 ! encoding: [0x80,0xa0,0x40,0x02]
6 cmp %g1, %g2
7 ! CHECK: cmp %g1, 5 ! encoding: [0x80,0xa0,0x60,0x05]
8 cmp %g1, 5
10 ! jmp and call are tested in sparc-ctrl-instructions.
12 ! CHECK: tst %g1 ! encoding: [0x80,0x90,0x40,0x00]
13 tst %g1
15 ! CHECK: ret ! encoding: [0x81,0xc7,0xe0,0x08]
16 ret
17 ! CHECK: retl ! encoding: [0x81,0xc3,0xe0,0x08]
18 retl
20 ! CHECK: restore ! encoding: [0x81,0xe8,0x00,0x00]
21 restore
22 ! CHECK: save ! encoding: [0x81,0xe0,0x00,0x00]
23 save
25 ! CHECK: sethi %hi(40000), %g1 ! encoding: [0x03,0b00AAAAAA,A,A]
26 ! CHECK: ! fixup A - offset: 0, value: %hi(40000), kind: fixup_sparc_hi22
27 ! CHECK: or %g1, %lo(40000), %g1 ! encoding: [0x82,0x10,0b011000AA,A]
28 ! CHECK: ! fixup A - offset: 0, value: %lo(40000), kind: fixup_sparc_lo10
29 set 40000, %g1
30 ! CHECK: mov 1, %g1 ! encoding: [0x82,0x10,0x20,0x01]
31 set 1, %g1
32 ! CHECK: sethi %hi(32768), %g1 ! encoding: [0x03,0b00AAAAAA,A,A]
33 ! CHECK: ! fixup A - offset: 0, value: %hi(32768), kind: fixup_sparc_hi22
34 set 32768, %g1
36 ! Expect a 'sethi' without an 'or'.
37 ! CHECK: sethi %hi(268431360), %o1 ! encoding: [0x13,0b00AAAAAA,A,A]
38 ! CHECK: ! fixup A - offset: 0, value: %hi(268431360), kind: fixup_sparc_hi22
39 set 0x0ffff000, %o1
41 ! CHECK: sethi %hi(268433408), %o1 ! encoding: [0x13,0b00AAAAAA,A,A]
42 ! CHECK: ! fixup A - offset: 0, value: %hi(268433408), kind: fixup_sparc_hi22
43 set 0x0ffff800, %o1
45 ! This is the boundary case that uses the lowest of the 22 bits in sethi.
46 ! CHECK: sethi %hi(268434432), %o1 ! encoding: [0x13,0b00AAAAAA,A,A]
47 ! CHECK: ! fixup A - offset: 0, value: %hi(268434432), kind: fixup_sparc_hi22
48 set 0x0ffffc00, %o1
50 ! Now the synthetic instruction becomes two instructions.
51 ! CHECK: sethi %hi(2147483647), %o1 ! encoding: [0x13,0b00AAAAAA,A,A]
52 ! CHECK: ! fixup A - offset: 0, value: %hi(2147483647), kind: fixup_sparc_hi22
53 ! CHECK: or %o1, %lo(2147483647), %o1 ! encoding: [0x92,0x12,0b011000AA,A]
54 ! CHECK: ! fixup A - offset: 0, value: %lo(2147483647), kind: fixup_sparc_lo10
55 set 2147483647, %o1
57 ! CHECK: xnor %g1, %g0, %g2 ! encoding: [0x84,0x38,0x40,0x00]
58 not %g1, %g2
59 ! CHECK: xnor %g1, %g0, %g1 ! encoding: [0x82,0x38,0x40,0x00]
60 not %g1
62 ! CHECK: sub %g0, %g1, %g2 ! encoding: [0x84,0x20,0x00,0x01]
63 neg %g1, %g2
64 ! CHECK: sub %g0, %g1, %g1 ! encoding: [0x82,0x20,0x00,0x01]
65 neg %g1
67 ! CHECK: add %g1, 1, %g1 ! encoding: [0x82,0x00,0x60,0x01]
68 inc %g1
69 ! CHECK: add %g1, 55, %g1 ! encoding: [0x82,0x00,0x60,0x37]
70 inc 55, %g1
71 ! CHECK: addcc %g1, 1, %g1 ! encoding: [0x82,0x80,0x60,0x01]
72 inccc %g1
73 ! CHECK: addcc %g1, 55, %g1 ! encoding: [0x82,0x80,0x60,0x37]
74 inccc 55, %g1
76 ! CHECK: sub %g1, 1, %g1 ! encoding: [0x82,0x20,0x60,0x01]
77 dec %g1
78 ! CHECK: sub %g1, 55, %g1 ! encoding: [0x82,0x20,0x60,0x37]
79 dec 55, %g1
80 ! CHECK: subcc %g1, 1, %g1 ! encoding: [0x82,0xa0,0x60,0x01]
81 deccc %g1
82 ! CHECK: subcc %g1, 55, %g1 ! encoding: [0x82,0xa0,0x60,0x37]
83 deccc 55, %g1
85 ! CHECK: andcc %g2, %g1, %g0 ! encoding: [0x80,0x88,0x80,0x01]
86 btst %g1, %g2
87 ! CHECK: andcc %g2, 4, %g0 ! encoding: [0x80,0x88,0xa0,0x04]
88 btst 4, %g2
89 ! CHECK: or %g2, %g1, %g2 ! encoding: [0x84,0x10,0x80,0x01]
90 bset %g1, %g2
91 ! CHECK: or %g2, 4, %g2 ! encoding: [0x84,0x10,0xa0,0x04]
92 bset 4, %g2
93 ! CHECK: andn %g2, %g1, %g2 ! encoding: [0x84,0x28,0x80,0x01]
94 bclr %g1, %g2
95 ! CHECK: andn %g2, 4, %g2 ! encoding: [0x84,0x28,0xa0,0x04]
96 bclr 4, %g2
97 ! CHECK: xor %g2, %g1, %g2 ! encoding: [0x84,0x18,0x80,0x01]
98 btog %g1, %g2
99 ! CHECK: xor %g2, 4, %g2 ! encoding: [0x84,0x18,0xa0,0x04]
100 btog 4, %g2
102 ! CHECK: mov %g0, %g1 ! encoding: [0x82,0x10,0x00,0x00]
103 clr %g1
104 ! CHECK: stb %g0, [%g1+%g2] ! encoding: [0xc0,0x28,0x40,0x02]
105 clrb [%g1+%g2]
106 ! CHECK: sth %g0, [%g1+%g2] ! encoding: [0xc0,0x30,0x40,0x02]
107 clrh [%g1+%g2]
108 ! CHECK: st %g0, [%g1+%g2] ! encoding: [0xc0,0x20,0x40,0x02]
109 clr [%g1+%g2]
111 ! mov reg_or_imm,reg tested in sparc-alu-instructions.s
113 ! CHECK: rd %y, %i0 ! encoding: [0xb1,0x40,0x00,0x00]
114 mov %y, %i0
115 ! CHECK: rd %asr1, %i0 ! encoding: [0xb1,0x40,0x40,0x00]
116 mov %asr1, %i0
117 ! CHECK: rd %psr, %i0 ! encoding: [0xb1,0x48,0x00,0x00]
118 mov %psr, %i0
119 ! CHECK: rd %wim, %i0 ! encoding: [0xb1,0x50,0x00,0x00]
120 mov %wim, %i0
121 ! CHECK: rd %tbr, %i0 ! encoding: [0xb1,0x58,0x00,0x00]
122 mov %tbr, %i0
124 ! CHECK: wr %g0, %i0, %y ! encoding: [0x81,0x80,0x00,0x18]
125 mov %i0, %y
126 ! CHECK: wr %g0, 5, %y ! encoding: [0x81,0x80,0x20,0x05]
127 mov 5, %y
128 ! CHECK: wr %g0, %i0, %asr15 ! encoding: [0x9f,0x80,0x00,0x18]
129 mov %i0, %asr15
130 ! CHECK: wr %g0, 5, %asr15 ! encoding: [0x9f,0x80,0x20,0x05]
131 mov 5, %asr15
132 ! CHECK: wr %g0, %i0, %psr ! encoding: [0x81,0x88,0x00,0x18]
133 mov %i0, %psr
134 ! CHECK: wr %g0, 5, %psr ! encoding: [0x81,0x88,0x20,0x05]
135 mov 5, %psr
136 ! CHECK: wr %g0, %i0, %wim ! encoding: [0x81,0x90,0x00,0x18]
137 mov %i0, %wim
138 ! CHECK: wr %g0, 5, %wim ! encoding: [0x81,0x90,0x20,0x05]
139 mov 5, %wim
140 ! CHECK: wr %g0, %i0, %tbr ! encoding: [0x81,0x98,0x00,0x18]
141 mov %i0, %tbr
142 ! CHECK: wr %g0, 5, %tbr ! encoding: [0x81,0x98,0x20,0x05]
143 mov 5, %tbr
145 ! Other aliases
146 ! CHECK: wr %g0, %i0, %y ! encoding: [0x81,0x80,0x00,0x18]
147 wr %i0, %y
148 ! CHECK: wr %g0, 5, %y ! encoding: [0x81,0x80,0x20,0x05]
149 wr 5, %y
150 ! CHECK: wr %g0, %i0, %asr15 ! encoding: [0x9f,0x80,0x00,0x18]
151 wr %i0, %asr15
152 ! CHECK: wr %g0, 5, %asr15 ! encoding: [0x9f,0x80,0x20,0x05]
153 wr 5, %asr15
154 ! CHECK: wr %g0, %i0, %psr ! encoding: [0x81,0x88,0x00,0x18]
155 wr %i0, %psr
156 ! CHECK: wr %g0, 5, %psr ! encoding: [0x81,0x88,0x20,0x05]
157 wr 5, %psr
158 ! CHECK: wr %g0, %i0, %wim ! encoding: [0x81,0x90,0x00,0x18]
159 wr %i0, %wim
160 ! CHECK: wr %g0, 5, %wim ! encoding: [0x81,0x90,0x20,0x05]
161 wr 5, %wim
162 ! CHECK: wr %g0, %i0, %tbr ! encoding: [0x81,0x98,0x00,0x18]
163 wr %i0, %tbr
164 ! CHECK: wr %g0, 5, %tbr ! encoding: [0x81,0x98,0x20,0x05]
165 wr 5, %tbr
167 ! The following tests exercise 'set' in such a way that its output differs
168 ! depending on whether targeting V8 or V9.
170 ! RUN: llvm-mc %s -arch=sparc -show-encoding | FileCheck %s --check-prefix=V8
171 ! RUN: llvm-mc %s -arch=sparcv9 -show-encoding | FileCheck %s --check-prefix=V9
173 ! V8: mov -1, %o1 ! encoding: [0x92,0x10,0x3f,0xff]
174 ! V9: sethi %hi(-1), %o1 ! encoding: [0x13,0b00AAAAAA,A,A]
175 ! V9: ! fixup A - offset: 0, value: %hi(-1), kind: fixup_sparc_hi22
176 ! V9: or %o1, %lo(-1), %o1 ! encoding: [0x92,0x12,0b011000AA,A]
177 ! V9: ! fixup A - offset: 0, value: %lo(-1), kind: fixup_sparc_lo10
178 set 0xffffffff, %o1
180 ! V8: mov -2, %o1 ! encoding: [0x92,0x10,0x3f,0xfe]
181 ! V9: sethi %hi(-2), %o1 ! encoding: [0x13,0b00AAAAAA,A,A]
182 ! V9: ! fixup A - offset: 0, value: %hi(-2), kind: fixup_sparc_hi22
183 ! V9: or %o1, %lo(-2), %o1 ! encoding: [0x92,0x12,0b011000AA,A]
184 ! V9: ! fixup A - offset: 0, value: %lo(-2), kind: fixup_sparc_lo10
185 set 0xfffffffe, %o1
187 ! V8: mov -16, %o1 ! encoding: [0x92,0x10,0x3f,0xf0]
188 ! V9: sethi %hi(-16), %o1 ! encoding: [0x13,0b00AAAAAA,A,A]
189 ! V9: ! fixup A - offset: 0, value: %hi(-16), kind: fixup_sparc_hi22
190 ! V9: or %o1, %lo(-16), %o1 ! encoding: [0x92,0x12,0b011000AA,A]
191 ! V9: ! fixup A - offset: 0, value: %lo(-16), kind: fixup_sparc_lo10
192 set 0xfffffff0, %o1
194 ! V8: mov -256, %o1 ! encoding: [0x92,0x10,0x3f,0x00]
195 ! V9: sethi %hi(-256), %o1 ! encoding: [0x13,0b00AAAAAA,A,A]
196 ! V9: ! fixup A - offset: 0, value: %hi(-256), kind: fixup_sparc_hi22
197 ! V9: or %o1, %lo(-256), %o1 ! encoding: [0x92,0x12,0b011000AA,A]
198 ! V9: ! fixup A - offset: 0, value: %lo(-256), kind: fixup_sparc_lo10
199 set 0xffffff00, %o1
201 ! V8: mov -4096, %o1 ! encoding: [0x92,0x10,0x30,0x00]
202 ! V9: sethi %hi(-4096), %o1 ! encoding: [0x13,0b00AAAAAA,A,A]
203 ! V9: ! fixup A - offset: 0, value: %hi(-4096), kind: fixup_sparc_hi22
204 set 0xfffff000, %o1
206 ! These results are the same for V8 and V9, so this test could have
207 ! been with the others that weren't segregated by architecture,
208 ! but logically it belongs here as a boundary case.
209 ! V8: sethi %hi(-8192), %o1 ! encoding: [0x13,0b00AAAAAA,A,A]
210 ! V8: ! fixup A - offset: 0, value: %hi(-8192), kind: fixup_sparc_hi22
211 ! V9: sethi %hi(-8192), %o1 ! encoding: [0x13,0b00AAAAAA,A,A]
212 ! V9: ! fixup A - offset: 0, value: %hi(-8192), kind: fixup_sparc_hi22
213 set 0xffffe000, %o1