1 @ RUN
: llvm-mc
-triple thumbv7a-
-none-eabi
-arm-implicit-it
=always
< %s
-show-encoding | FileCheck
%s
10 @ Multiple instructions
, same condition
23 @ Multiple instructions
, equal but opposite conditions
36 @ Multiple instructions
, unrelated conditions
52 @ More than
4 instructions eligible for
a block
87 @ Flush on
a section-change directive
110 @ Flush on an ISA change
(even to the same ISA
)
128 @ Flush on an arch
, cpu
or fpu change
147 @ Flush on an unpredicable instruction
149 @ CHECK-LABEL
: test10
164 @ Flush when reaching an explicit IT instruction
166 @ CHECK-LABEL
: test11
175 @ Don
't extend an explicit IT instruction
177 @ CHECK-LABEL: test12
186 @ Branch-like instructions can only be used at the end of an IT block, so
189 @ CHECK-LABEL: test13
204 tbheq [r0, r1, lsl #1]
212 ldmiaeq r0!, {r1, pc}
214 ldmdbeq r0!, {r1, pc}
220 @ CHECK: addeq pc, r0
222 @ CHECK: addeq pc, sp, pc
224 @ CHECK: ldreq.w pc, [r0, #4]
226 @ CHECK: ldreq pc, [r0, #-4]
228 @ CHECK: ldreq.w pc, [r0, r1]
230 @ CHECK: ldreq.w pc, [pc, #-0]
232 @ CHECK: moveq pc, r0
244 @ CHECK: tbbeq [r0, r1]
246 @ CHECK: tbheq [r0, r1, lsl #1]
260 @ CHECK: ldmeq.w r0, {pc}
262 @ CHECK: ldmeq.w r0!, {r1, pc}
264 @ CHECK: ldmdbeq r0, {pc}
266 @ CHECK: ldmdbeq r0!, {r1, pc}
274 @ Thumb 16-bit ALU instructions set the flags iff they are not in an IT block,
275 @ so instruction matching must change when generating an implicit IT block.
277 @ CHECK-LABEL: test14
278 @ Outside an IT block, the 16-bit encoding must set flags
280 @ CHECK:add.w r0, r0, #1 @ encoding: [0x00,0xf1,0x01,0x00]
282 @ CHECK: adds r0, #1 @ encoding: [0x01,0x30]
283 @ Inside an IT block, the 16-bit encoding can not set flags
286 @ CHECK: addeq r0, #1 @ encoding: [0x01,0x30]
288 @ CHECK: addseq.w r0, r0, #1 @ encoding: [0x10,0xf1,0x01,0x00]
290 @ Some variants of the B instruction have their own condition code field, and
291 @ are not valid in IT blocks.
293 @ CHECK-LABEL: test15
294 @ Outside of an IT block, the 4 variants (narrow/wide,
295 @ predicated/non-predicated) are selected as normal, and the predicated
296 @ encodings are used instead of opening a new IT block:
298 @ CHECK: b #256 @ encoding: [0x80,0xe0]
300 @ CHECK: b.w #2048 @ encoding: [0x00,0xf0,0x00,0xbc]
303 @ CHECK: beq #4 @ encoding: [0x02,0xd0]
306 @ CHECK: beq.w #256 @ encoding: [0x00,0xf0,0x80,0x80]
308 @ We could support "beq #0x100000" to "beq #0x1fffffc" by using t2Bcc in
309 @ an IT block (these currently fail as the target is out of range). However, long
310 @ ranges like this are rarely assembly-time constants, so this probably isn't
313 @ If we already have an open IT block
, we can use the non-predicated encodings
,
314 @ which have
a greater range
:
318 @ CHECK
: addeq
r0, r1
319 @ CHECK
: beq #4 @ encoding: [0x02,0xe0]
323 @ CHECK
: addeq
r0, r1
324 @ CHECK
: beq #256 @ encoding: [0x80,0xe0]
328 @ CHECK
: addeq
r0, r1
329 @ CHECK
: beq.w
#2048 @ encoding: [0x00,0xf0,0x00,0xbc]
331 @ If we have an open but incompatible IT block
, we close it
and use the
332 @ self-predicated encodings
, without an IT block
:
336 @ CHECK
: addeq
r0, r1
337 @ CHECK
: bgt #4 @ encoding: [0x02,0xdc]
341 @ CHECK
: addeq
r0, r1
342 @ CHECK
: bgt.w
#256 @ encoding: [0x00,0xf3,0x80,0x80]
344 @ Breakpoint instructions are allowed in IT blocks
, but are always executed
345 @ regardless of the condition flags. We could continue an IT block through
346 @ them
, but currently do
not.
348 @ CHECK-LABEL
: test16
353 @ CHECK
: addeq
r0, r1
356 @ CHECK
: addeq
r0, r1
358 @ The
.if directive causes entire assembly statments to be dropped before they
359 @ reach the IT block generation code. This happens to
be exactly what we want
,
360 @
and allows IT blocks to extend into
and out of
.if blocks. Only one arm of the
361 @
.if will be seen by the IT state tracking code, so the subeq shouldn't have
364 @ CHECK-LABEL: test17
377 @ TODO: There are some other directives which we could continue through, such
378 @ as .set and .global, but we currently conservatively flush the IT block before
379 @ every directive (except for .if and friends, which are handled separately).
381 @ CHECK-LABEL: test18
390 @ The .rept directive can be used to create long IT blocks.
392 @ CHECK-LABEL: test19
398 @ CHECK: addeq r0, r1
399 @ CHECK: subne r0, r0, r1
400 @ CHECK: addeq r0, r1
401 @ CHECK: subne r0, r0, r1
403 @ CHECK: addeq r0, r1
404 @ CHECK: subne r0, r0, r1
406 @ Flush at end of file
408 @ CHECK-LABEL: test99