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