2011-07-20 03:13:28 +08:00
|
|
|
@ RUN: llvm-mc -triple armv7-unknown-unknown %s --show-encoding > %t
|
|
|
|
@ RUN: FileCheck < %t %s
|
2014-03-28 22:35:30 +08:00
|
|
|
@ RUN: llvm-mc -triple armebv7-unknown-unknown %s --show-encoding > %t
|
|
|
|
@ RUN: FileCheck --check-prefix=CHECK-BE < %t %s
|
2010-12-15 01:37:16 +08:00
|
|
|
|
2011-07-20 03:13:28 +08:00
|
|
|
bl _printf
|
|
|
|
@ CHECK: bl _printf @ encoding: [A,A,A,0xeb]
|
2012-03-30 17:15:32 +08:00
|
|
|
@ CHECK: @ fixup A - offset: 0, value: _printf, kind: fixup_arm_uncondbl
|
2014-03-28 22:35:30 +08:00
|
|
|
@ CHECK-BE: bl _printf @ encoding: [0xeb,A,A,A]
|
|
|
|
@ CHECK-BE: @ fixup A - offset: 0, value: _printf, kind: fixup_arm_uncondbl
|
2011-07-20 03:02:39 +08:00
|
|
|
|
2011-07-20 03:13:28 +08:00
|
|
|
mov r9, :lower16:(_foo)
|
|
|
|
movw r9, :lower16:(_foo)
|
|
|
|
movt r9, :upper16:(_foo)
|
|
|
|
|
|
|
|
@ CHECK: movw r9, :lower16:_foo @ encoding: [A,0x90'A',0b0000AAAA,0xe3]
|
|
|
|
@ CHECK: @ fixup A - offset: 0, value: _foo, kind: fixup_arm_movw_lo16
|
2014-03-28 22:35:30 +08:00
|
|
|
@ CHECK-BE: movw r9, :lower16:_foo @ encoding: [0xe3,0b0000AAAA,0x90'A',A]
|
|
|
|
@ CHECK-BE: @ fixup A - offset: 0, value: _foo, kind: fixup_arm_movw_lo16
|
2011-07-20 03:13:28 +08:00
|
|
|
@ CHECK: movw r9, :lower16:_foo @ encoding: [A,0x90'A',0b0000AAAA,0xe3]
|
|
|
|
@ CHECK: @ fixup A - offset: 0, value: _foo, kind: fixup_arm_movw_lo16
|
2014-03-28 22:35:30 +08:00
|
|
|
@ CHECK-BE: movw r9, :lower16:_foo @ encoding: [0xe3,0b0000AAAA,0x90'A',A]
|
|
|
|
@ CHECK-BE: @ fixup A - offset: 0, value: _foo, kind: fixup_arm_movw_lo16
|
2011-07-20 03:13:28 +08:00
|
|
|
@ CHECK: movt r9, :upper16:_foo @ encoding: [A,0x90'A',0b0100AAAA,0xe3]
|
|
|
|
@ CHECK: @ fixup A - offset: 0, value: _foo, kind: fixup_arm_movt_hi16
|
2014-03-28 22:35:30 +08:00
|
|
|
@ CHECK-BE: movt r9, :upper16:_foo @ encoding: [0xe3,0b0100AAAA,0x90'A',A]
|
|
|
|
@ CHECK-BE: @ fixup A - offset: 0, value: _foo, kind: fixup_arm_movt_hi16
|
2012-05-02 04:43:21 +08:00
|
|
|
|
2014-04-19 07:06:39 +08:00
|
|
|
mov r2, :lower16:fred
|
2012-05-02 04:43:21 +08:00
|
|
|
|
2014-04-19 07:06:39 +08:00
|
|
|
@ CHECK: movw r2, :lower16:fred @ encoding: [A,0x20'A',0b0000AAAA,0xe3]
|
2012-05-02 04:43:21 +08:00
|
|
|
@ CHECK: @ fixup A - offset: 0, value: fred, kind: fixup_arm_movw_lo16
|
2014-04-19 07:06:39 +08:00
|
|
|
@ CHECK-BE: movw r2, :lower16:fred @ encoding: [0xe3,0b0000AAAA,0x20'A',A]
|
2014-03-28 22:35:30 +08:00
|
|
|
@ CHECK-BE: @ fixup A - offset: 0, value: fred, kind: fixup_arm_movw_lo16
|
Fix for pr24346: arm asm label calculation error in sub
Some ARM instructions encode 32-bit immediates as a 8-bit integer (0-255)
and a 4-bit rotation (0-30, even) in its least significant 12 bits. The
original fixup, FK_Data_4, patches the instruction by the value bit-to-bit,
regardless of the encoding. For example, assuming the label L1 and L2 are
0x0 and 0x104 respectively, the following instruction:
add r0, r0, #(L2 - L1) ; expects 0x104, i.e., 260
would be assembled to the following, which adds 1 to r0, instead of 260:
e2800104 add r0, r0, #4, 2 ; equivalently 1
The new fixup kind fixup_arm_mod_imm takes care of the encoding:
e2800f41 add r0, r0, #260
Patch by Ting-Yuan Huang!
llvm-svn: 265122
2016-04-01 17:40:47 +08:00
|
|
|
|
|
|
|
add r0, r0, #(L1 - L2)
|
|
|
|
|
|
|
|
@ CHECK: add r0, r0, #L1-L2 @ encoding: [A,0b0000AAAA,0x80,0xe2]
|
|
|
|
@ CHECK: @ fixup A - offset: 0, value: L1-L2, kind: fixup_arm_mod_imm
|
|
|
|
@ CHECK-BE: add r0, r0, #L1-L2 @ encoding: [0xe2,0x80,0b0000AAAA,A]
|
|
|
|
@ CHECK-BE: @ fixup A - offset: 0, value: L1-L2, kind: fixup_arm_mod_imm
|