1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-23 21:13:02 +02:00
llvm-mirror/test/MC/ARM/ldr-pseudo-cond.s
Renato Golin fa6e1c461b [ARM] Support and tests for transform of LDR rt, = to MOV
This change implements the transformation in processInstruction() for the
LDR rt, =expression to MOV rt, expression when the expression can be evaluated
and can fit into the immediate field of the MOV or a MVN.

Across the ARM and Thumb instruction sets there are several cases to consider,
each with a different range of representatble constants.

In ARM we have:
 * Modified immediate (All ARM architectures)
 * MOVW (v6t2 and above)

In Thumb we have:
 * Modified immediate (v6t2, v7m and v8m.mainline)
 * MOVW (v6t2, v7m, v8.mainline and v8m.baseline)
 * Narrow Thumb MOV that can be used in an IT block (non flag-setting)

If the immediate fits any of the available alternatives then we make the transformation.

Fixes 25722.

Patch by Peter Smith.

llvm-svn: 269354
2016-05-12 21:22:42 +00:00

56 lines
1.3 KiB
ArmAsm

@RUN: llvm-mc -triple armv7-unknown-linux-gnueabi %s | FileCheck --check-prefix=CHECK-ARM --check-prefix=CHECK %s
@RUN: llvm-mc -triple thumbv7-unknown-linux-gnueabi %s | FileCheck --check-prefix=CHECK-THUMB2 --check-prefix=CHECK %s
@
@ Check that ldr to constant pool correctly transfers the condition codes
@
@ simple test
.section a,"ax",%progbits
@ CHECK-LABEL: f0:
f0:
it eq
ldreq r0, =0x10002
@ CHECK: ldreq r0, .Ltmp[[TMP0:[0-9]+]]
@ loading multiple constants
.section b,"ax",%progbits
@ CHECK-LABEL: f1:
f1:
ite eq
ldreq r0, =0x10003
@ CHECK: ldreq r0, .Ltmp[[TMP1:[0-9]+]]
ldrne r0, =0x10004
@ CHECK: ldrne r0, .Ltmp[[TMP2:[0-9]+]]
@ transformation to mov
.section c, "ax", %progbits
@ CHECK-LABEL: f2:
f2:
@ Can use the narrow Thumb mov as it does not set flags in an IT block
it eq
ldreq r1, =0x1
@ CHECK: moveq r1, #1
@ Must use the wide Thumb mov if the constant can't be represented
ite eq
ldreq r2, = 0x1f000000
@ CHECK-ARM moveq r2, #520093696
@ CHECK-THUMB2 moveq.w r2, #520093696
ldrne r3, = 0x00001234
@ CHECK movwne r2, #4660
@
@ Constant Pools
@
@ CHECK: .section a,"ax",%progbits
@ CHECK: .p2align 2
@ CHECK: .Ltmp[[TMP0]]
@ CHECK: .long 65538
@ CHECK: .section b,"ax",%progbits
@ CHECK: .p2align 2
@ CHECK: .Ltmp[[TMP1]]
@ CHECK: .long 65539
@ CHECK: .Ltmp[[TMP2]]
@ CHECK: .long 65540