[ARM] Better OR's for MVE compares
[llvm-core.git] / test / MC / ARM / thumb2-branches.s
blob51f01e320d8348862a3bf15bb1e8c6177c164e8b
1 @ RUN: llvm-mc -triple=thumbv7-apple-darwin -mcpu=cortex-a8 -show-encoding < %s | FileCheck %s
3 @------------------------------------------------------------------------------
4 @ unconditional branches accept narrow suffix and encode to short encodings
5 @------------------------------------------------------------------------------
7 b.n #-2048
8 b.n #2046
10 @ CHECK: b #-2048 @ encoding: [0x00,0xe4]
11 @ CHECK: b #2046 @ encoding: [0xff,0xe3]
13 @------------------------------------------------------------------------------
14 @ unconditional branches accept wide suffix and encode to wide encodings
15 @------------------------------------------------------------------------------
17 b.w #-2048
18 b.w #2046
19 b.w #-1677216
20 b.w #1677214
22 @ CHECK: b.w #-2048 @ encoding: [0xff,0xf7,0x00,0xbc]
23 @ CHECK: b.w #2046 @ encoding: [0x00,0xf0,0xff,0xbb]
24 @ CHECK: b.w #-1677216 @ encoding: [0x66,0xf6,0x30,0xbc]
25 @ CHECK: b.w #1677214 @ encoding: [0x99,0xf1,0xcf,0xbb]
27 @------------------------------------------------------------------------------
28 @ unconditional branches without width suffix encode depending of offset size
29 @------------------------------------------------------------------------------
31 b #-2048
32 b #2046
33 b #-2050
34 b #2048
35 b #-1677216
36 b #1677214
38 @ CHECK: b #-2048 @ encoding: [0x00,0xe4]
39 @ CHECK: b #2046 @ encoding: [0xff,0xe3]
40 @ CHECK: b.w #-2050 @ encoding: [0xff,0xf7,0xff,0xbb]
41 @ CHECK: b.w #2048 @ encoding: [0x00,0xf0,0x00,0xbc]
42 @ CHECK: b.w #-1677216 @ encoding: [0x66,0xf6,0x30,0xbc]
43 @ CHECK: b.w #1677214 @ encoding: [0x99,0xf1,0xcf,0xbb]
45 @------------------------------------------------------------------------------
46 @ unconditional branches with width narrow suffix in IT block
47 @------------------------------------------------------------------------------
49 it eq
50 beq.n #-2048
51 it ne
52 bne.n #-2046
54 @ CHECK: it eq @ encoding: [0x08,0xbf]
55 @ CHECK: beq #-2048 @ encoding: [0x00,0xe4]
56 @ CHECK: it ne @ encoding: [0x18,0xbf]
57 @ CHECK: bne #-2046 @ encoding: [0x01,0xe4]
59 @------------------------------------------------------------------------------
60 @ unconditional branches with wide suffix in IT block
61 @------------------------------------------------------------------------------
63 it gt
64 bgt.w #-2048
65 it le
66 ble.w #2046
67 it ge
68 bge.w #-1677216
69 it lt
70 blt.w #1677214
72 @ CHECK: it gt @ encoding: [0xc8,0xbf]
73 @ CHECK: bgt.w #-2048 @ encoding: [0xff,0xf7,0x00,0xbc]
74 @ CHECK: it le @ encoding: [0xd8,0xbf]
75 @ CHECK: ble.w #2046 @ encoding: [0x00,0xf0,0xff,0xbb]
76 @ CHECK: it ge @ encoding: [0xa8,0xbf]
77 @ CHECK: bge.w #-1677216 @ encoding: [0x66,0xf6,0x30,0xbc]
78 @ CHECK: it lt @ encoding: [0xb8,0xbf]
79 @ CHECK: blt.w #1677214 @ encoding: [0x99,0xf1,0xcf,0xbb]
81 @------------------------------------------------------------------------------
82 @ conditional branches accept narrow suffix and encode to short encodings
83 @------------------------------------------------------------------------------
85 beq.n #-256
86 bne.n #254
88 @ CHECK: beq #-256 @ encoding: [0x80,0xd0]
89 @ CHECK: bne #254 @ encoding: [0x7f,0xd1]
91 @------------------------------------------------------------------------------
92 @ unconditional branches accept wide suffix and encode to wide encodings
93 @------------------------------------------------------------------------------
95 bmi.w #-256
96 bne.w #254
97 blt.w #-1048576
98 bge.w #1048574
100 @ CHECK: bmi.w #-256 @ encoding: [0x3f,0xf5,0x80,0xaf]
101 @ CHECK: bne.w #254 @ encoding: [0x40,0xf0,0x7f,0x80]
102 @ CHECK: blt.w #-1048576 @ encoding: [0xc0,0xf6,0x00,0x80]
103 @ CHECK: bge.w #1048574 @ encoding: [0xbf,0xf2,0xff,0xaf]
105 @------------------------------------------------------------------------------
106 @ unconditional branches without width suffix encode depending of offset size
107 @------------------------------------------------------------------------------
109 bne #-256
110 bgt #254
111 bne #-258
112 bgt #256
113 bne #-1048576
114 bgt #1048574
116 @ CHECK: bne #-256 @ encoding: [0x80,0xd1]
117 @ CHECK: bgt #254 @ encoding: [0x7f,0xdc]
118 @ CHECK: bne.w #-258 @ encoding: [0x7f,0xf4,0x7f,0xaf]
119 @ CHECK: bgt.w #256 @ encoding: [0x00,0xf3,0x80,0x80]
120 @ CHECK: bne.w #-1048576 @ encoding: [0x40,0xf4,0x00,0x80]
121 @ CHECK: bgt.w #1048574 @ encoding: [0x3f,0xf3,0xff,0xaf]
123 @------------------------------------------------------------------------------
124 @ same branch insturction encoding to conditional or unconditional depending
125 @ on whether it is in an IT block or not
126 @------------------------------------------------------------------------------
128 it eq
129 addeq r0, r1
130 bne #128
132 @ CHECK: it eq @ encoding: [0x08,0xbf]
133 @ CHECK: addeq r0, r1 @ encoding: [0x08,0x44]
134 @ CHECK: bne #128 @ encoding: [0x40,0xd1]
136 ite eq
137 addeq r0, r1
138 bne #128
140 @ CHECK: ite eq @ encoding: [0x0c,0xbf]
141 @ CHECK: addeq r0, r1 @ encoding: [0x08,0x44]
142 @ CHECK: bne #128 @ encoding: [0x40,0xe0]
144 @ RUN: llvm-mc -triple=thumbv7-apple-darwin -mcpu=cortex-a8 -show-encoding < %s | FileCheck %s
146 @------------------------------------------------------------------------------
147 @ unconditional branches accept narrow suffix and encode to short encodings
148 @------------------------------------------------------------------------------
150 b.n #-2048
151 b.n #2046
153 @ CHECK: b #-2048 @ encoding: [0x00,0xe4]
154 @ CHECK: b #2046 @ encoding: [0xff,0xe3]
156 @------------------------------------------------------------------------------
157 @ unconditional branches accept wide suffix and encode to wide encodings
158 @------------------------------------------------------------------------------
160 b.w #-2048
161 b.w #2046
162 b.w #-1677216
163 b.w #1677214
165 @ CHECK: b.w #-2048 @ encoding: [0xff,0xf7,0x00,0xbc]
166 @ CHECK: b.w #2046 @ encoding: [0x00,0xf0,0xff,0xbb]
167 @ CHECK: b.w #-1677216 @ encoding: [0x66,0xf6,0x30,0xbc]
168 @ CHECK: b.w #1677214 @ encoding: [0x99,0xf1,0xcf,0xbb]
170 @------------------------------------------------------------------------------
171 @ unconditional branches without width suffix encode depending of offset size
172 @------------------------------------------------------------------------------
174 b #-2048
175 b #2046
176 b #-2050
177 b #2048
178 b #-1677216
179 b #1677214
181 @ CHECK: b #-2048 @ encoding: [0x00,0xe4]
182 @ CHECK: b #2046 @ encoding: [0xff,0xe3]
183 @ CHECK: b.w #-2050 @ encoding: [0xff,0xf7,0xff,0xbb]
184 @ CHECK: b.w #2048 @ encoding: [0x00,0xf0,0x00,0xbc]
185 @ CHECK: b.w #-1677216 @ encoding: [0x66,0xf6,0x30,0xbc]
186 @ CHECK: b.w #1677214 @ encoding: [0x99,0xf1,0xcf,0xbb]
188 @------------------------------------------------------------------------------
189 @ unconditional branches with width narrow suffix in IT block
190 @------------------------------------------------------------------------------
192 it eq
193 beq.n #-2048
194 it ne
195 bne.n #-2046
197 @ CHECK: it eq @ encoding: [0x08,0xbf]
198 @ CHECK: beq #-2048 @ encoding: [0x00,0xe4]
199 @ CHECK: it ne @ encoding: [0x18,0xbf]
200 @ CHECK: bne #-2046 @ encoding: [0x01,0xe4]
202 @------------------------------------------------------------------------------
203 @ unconditional branches with wide suffix in IT block
204 @------------------------------------------------------------------------------
206 it gt
207 bgt.w #-2048
208 it le
209 ble.w #2046
210 it ge
211 bge.w #-1677216
212 it lt
213 blt.w #1677214
215 @ CHECK: it gt @ encoding: [0xc8,0xbf]
216 @ CHECK: bgt.w #-2048 @ encoding: [0xff,0xf7,0x00,0xbc]
217 @ CHECK: it le @ encoding: [0xd8,0xbf]
218 @ CHECK: ble.w #2046 @ encoding: [0x00,0xf0,0xff,0xbb]
219 @ CHECK: it ge @ encoding: [0xa8,0xbf]
220 @ CHECK: bge.w #-1677216 @ encoding: [0x66,0xf6,0x30,0xbc]
221 @ CHECK: it lt @ encoding: [0xb8,0xbf]
222 @ CHECK: blt.w #1677214 @ encoding: [0x99,0xf1,0xcf,0xbb]
224 @------------------------------------------------------------------------------
225 @ conditional branches accept narrow suffix and encode to short encodings
226 @------------------------------------------------------------------------------
228 beq.n #-256
229 bne.n #254
231 @ CHECK: beq #-256 @ encoding: [0x80,0xd0]
232 @ CHECK: bne #254 @ encoding: [0x7f,0xd1]
234 @------------------------------------------------------------------------------
235 @ unconditional branches accept wide suffix and encode to wide encodings
236 @------------------------------------------------------------------------------
238 bmi.w #-256
239 bne.w #254
240 blt.w #-1048576
241 bge.w #1048574
243 @ CHECK: bmi.w #-256 @ encoding: [0x3f,0xf5,0x80,0xaf]
244 @ CHECK: bne.w #254 @ encoding: [0x40,0xf0,0x7f,0x80]
245 @ CHECK: blt.w #-1048576 @ encoding: [0xc0,0xf6,0x00,0x80]
246 @ CHECK: bge.w #1048574 @ encoding: [0xbf,0xf2,0xff,0xaf]
248 @------------------------------------------------------------------------------
249 @ unconditional branches without width suffix encode depending of offset size
250 @------------------------------------------------------------------------------
252 bne #-256
253 bgt #254
254 bne #-258
255 bgt #256
256 bne #-1048576
257 bgt #1048574
259 @ CHECK: bne #-256 @ encoding: [0x80,0xd1]
260 @ CHECK: bgt #254 @ encoding: [0x7f,0xdc]
261 @ CHECK: bne.w #-258 @ encoding: [0x7f,0xf4,0x7f,0xaf]
262 @ CHECK: bgt.w #256 @ encoding: [0x00,0xf3,0x80,0x80]
263 @ CHECK: bne.w #-1048576 @ encoding: [0x40,0xf4,0x00,0x80]
264 @ CHECK: bgt.w #1048574 @ encoding: [0x3f,0xf3,0xff,0xaf]
266 @------------------------------------------------------------------------------
267 @ same branch insturction encoding to conditional or unconditional depending
268 @ on whether it is in an IT block or not
269 @------------------------------------------------------------------------------
271 it eq
272 addeq r0, r1
273 bne #128
275 @ CHECK: it eq @ encoding: [0x08,0xbf]
276 @ CHECK: addeq r0, r1 @ encoding: [0x08,0x44]
277 @ CHECK: bne #128 @ encoding: [0x40,0xd1]
279 ite eq
280 addeq r0, r1
281 bne #128
283 @ CHECK: ite eq @ encoding: [0x0c,0xbf]
284 @ CHECK: addeq r0, r1 @ encoding: [0x08,0x44]
285 @ CHECK: bne #128 @ encoding: [0x40,0xe0]
288 @------------------------------------------------------------------------------
289 @ Branch targets destined for ARM mode must == 0 (mod 4), otherwise (mod 2).
290 @------------------------------------------------------------------------------
292 b #2
293 bl #2
294 beq #2
295 cbz r0, #2
296 @ N.b. destination is "align(PC, 4) + imm" so imm is still 4-byte
297 @ aligned even though current PC may not and destination must be.
298 blx #4
300 @ CHECK: b #2 @ encoding: [0x01,0xe0]
301 @ CHECK: bl #2 @ encoding: [0x00,0xf0,0x01,0xf8]
302 @ CHECK: beq #2 @ encoding: [0x01,0xd0]
303 @ CHECK: cbz r0, #2 @ encoding: [0x08,0xb1]
304 @ CHECK: blx #4 @ encoding: [0x00,0xf0,0x02,0xe8]