llvm-6502/test/MC/ARM
Jason W Kim 861b9c6a39 This fixes one divergence between LLVM and binutils for ARM in the
text section.

Assume the following bit of annotated assembly:

.section	.data.rel.ro,"aw",%progbits
.align	2
.LAlpha:
.long	startval(GOTOFF)

.text
.align	2
.type	main,%function
.align	4

main: ;;; assume "main" starts at offset 0x20
0x0	push	{r11, lr}
0x4	movw	r0, :lower16:(.LAlpha-(.LBeta+8))
;;; ==> (.AddrOf(.LAlpha) - ((.AddrOf(.LBeta) - .AddrOf(".")) + 8)
;;; ==> (??? - ((16-4) + 8) = -20
0x8	movt	r0, :upper16:(.LAlpha-(.LBeta+8))
;;; ==> (.AddrOf(.LAlpha) - ((.AddrOf(.LBeta) - .AddrOf(".")) + 8)
;;; ==> (??? - ((16-8) + 8) = -16
0xc	... blah

.LBeta:
0x10	add	r0, pc, r0
0x14	... blah

.LGamma:
0x18	add	r1, pc, r1

Above snippet results in the following relocs in the .o file for the
first pair of movw/movt instructions

00000024 R_ARM_MOVW_PREL_NC .LAlpha
00000028 R_ARM_MOVT_PREL .LAlpha

And the encoded instructions in the .o file for main: must be

00000020 <main>:
20:	e92d4800 push	{fp, lr}
24:	e30f0fec movw	r0, #65516	; 0xffec i.e. -20
28:	e34f0ff0 movt	r0, #65520	; 0xfff0 i.e. -16

However, llc (prior to this commit) generates the following sequence

00000020 <main>:
20:	e92d4800 push	{fp, lr}
24:	e30f0fec movw	r0, #65516	; 0xffec - i.e. -20
28:	e34f0fff movt	r0, #65535	; 0xffff - i.e. -1

What has to happen in the ArmAsmBackend is that if the relocation is PC
relative, the 16 bits encoded as part of movw and movt must be both addends,
not addresses. It makes sense to encode addresses by right shifting the value
by 16, but the result is incorrect for PIC.
i.e., the right shift by 16 for movt is ONLY valid for the NON-PCRel case.

This change agrees with what GNU as does, and makes the PIC code run.

MC/ARM/elf-movt.s covers this case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131674 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-19 20:55:25 +00:00
..
arm_addrmode2.s Apply again changes to support ARM memory asm parsing. I removed 2011-03-31 23:26:08 +00:00
arm_addrmode3.s - Implement asm parsing support for LDRSBT, LDRHT, LDRSHT and STRHT 2011-04-04 17:18:19 +00:00
arm_fixups.s Teach ARM/MC/ELF to handle R_ARM_JUMP24 relocation type for conditional jumps. 2011-02-04 19:47:15 +00:00
arm_instructions.s Add asm parsing support w/ testcases for strex/ldrex family of instructions 2011-03-24 21:04:58 +00:00
arm_word_directive.s
bracket-darwin.s Restore r125595 (reverted in r126336) with modifications: 2011-02-24 21:59:22 +00:00
bracket-exprs.s split this test into arch specific pieces, so the ARM 2011-02-25 19:06:35 +00:00
darwin-ARM-reloc.s Move arch specific tests in arch specific directories. 2011-02-24 19:06:27 +00:00
darwin-Thumb-reloc.s Move arch specific tests in arch specific directories. 2011-02-24 19:06:27 +00:00
dg.exp
elf-eflags-eabi.s Teach ARM/MC/ELF about EF_ARM_EABI_VERSION. The magic number is set to 2011-02-04 21:41:11 +00:00
elf-movt.s This fixes one divergence between LLVM and binutils for ARM in the 2011-05-19 20:55:25 +00:00
elf-reloc-01.ll Write the section table and the section data in the same order that 2011-03-20 18:44:20 +00:00
elf-reloc-02.ll Write the section table and the section data in the same order that 2011-03-20 18:44:20 +00:00
elf-reloc-03.ll Write the section table and the section data in the same order that 2011-03-20 18:44:20 +00:00
full_line_comment.s Move arch specific tests in arch specific directories. 2011-02-24 19:06:27 +00:00
hilo-16bit-relocations.s Completed :lower16: / :upper16: support for movw / movt pairs on Darwin. 2011-01-14 02:38:49 +00:00
neon-abs-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-absdiff-encoding.s McARM: Flush out hard coded known non-predicated mnemonic list. 2011-01-10 21:01:03 +00:00
neon-add-encoding.s
neon-bitcount-encoding.s McARM: Flush out hard coded known non-predicated mnemonic list. 2011-01-10 21:01:03 +00:00
neon-bitwise-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-cmp-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-convert-encoding.s Add Neon VCVT instructions for f32 <-> f16 conversions. 2010-12-15 22:14:12 +00:00
neon-dup-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-minmax-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-mov-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-mul-accum-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-mul-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-neg-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-pairwise-encoding.s McARM: Flush out hard coded known non-predicated mnemonic list. 2011-01-10 21:01:03 +00:00
neon-reciprocal-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-reverse-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-satshift-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-shift-encoding.s * Correct encoding for VSRI. 2011-03-09 00:33:17 +00:00
neon-shiftaccum-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-shuffle-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-sub-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-table-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neon-vld-encoding.s
neon-vst-encoding.s
neont2-abs-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-absdiff-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-add-encoding.s Encode the 32-bit wide Thumb (and Thumb2) instructions with the high order 2010-12-03 22:31:40 +00:00
neont2-bitcount-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-bitwise-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-cmp-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-convert-encoding.s Add Neon VCVT instructions for f32 <-> f16 conversions. 2010-12-15 22:14:12 +00:00
neont2-dup-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-minmax-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-mov-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-mul-accum-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-mul-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-neg-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-pairwise-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-reciprocal-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-reverse-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-satshift-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-shift-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-shiftaccum-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-shuffle-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-sub-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-table-encoding.s Fix misspelled target triples in MC/ARM test commands. 2010-12-15 22:14:01 +00:00
neont2-vld-encoding.s Add correct Thumb2 encodings for NEON vst[1,2,3,4] and vld[1,2,3,4]. 2010-11-11 21:36:43 +00:00
neont2-vst-encoding.s Add correct Thumb2 encodings for NEON vst[1,2,3,4] and vld[1,2,3,4]. 2010-11-11 21:36:43 +00:00
prefetch.ll Fix test for non-darwin targets. 2011-02-01 01:16:18 +00:00
reg-list.s Sort the register list based on the *actual* register numbers rather than the 2011-01-12 21:20:59 +00:00
simple-encoding.ll Explicitly request -join-physregs for some tests that depend on it. 2011-05-04 19:01:59 +00:00
simple-fp-encoding.s Do AsmMatcher operand classification per-opcode. 2011-02-10 00:08:28 +00:00
thumb2_instructions.s McARM: Start marking T2 address operands as such, for the benefit of the parser. 2011-01-18 03:06:03 +00:00
thumb2.s Add asm parsing support w/ testcases for strex/ldrex family of instructions 2011-03-24 21:04:58 +00:00
thumb.s Fix encoding of Thumb BLX register instructions. Patch by Koan-Sin Tan. 2011-05-11 17:00:48 +00:00