llvm-mirror/test/MC/ARM
Sanne Wouda 472490f306 [ARM] [Assembler] Support negative immediates for A32, T32 and T16
Summary:
To support negative immediates for certain arithmetic instructions, the
instruction is converted to the inverse instruction with a negated (or inverted)
immediate. For example, "ADD r0, r1, #FFFFFFFF" cannot be encoded as an ADD
instruction.  However, "SUB r0, r1, #1" is equivalent.

These conversions are different from instruction aliases.  An alias maps
several assembler instructions onto one encoding.  A conversion, however, maps
an *invalid* instruction--e.g. with an immediate that cannot be represented in
the encoding--to a different (but equivalent) instruction.

Several instructions with negative immediates were being converted already, but
this was not systematically tested, nor did it cover all instructions.

This patch implements all possible substitutions for ARM, Thumb1 and
Thumb2 assembler and adds tests.  It also adds a feature flag
(-mattr=+no-neg-immediates) to turn these substitutions off.  This is
helpful for users who want their code to assemble to exactly what they
wrote.

Reviewers: t.p.northover, rovka, samparker, javed.absar, peter.smith, rengolin

Reviewed By: javed.absar

Subscribers: aadg, aemerson, llvm-commits

Differential Revision: https://reviews.llvm.org/D30571

llvm-svn: 298380
2017-03-21 14:59:17 +00:00
..
AlignedBundling
Windows [ARM] Check that the thumb COFF segment flag gets set on thumb windows 2016-07-27 14:37:18 +00:00
2010-11-30-reloc-movt.s
2013-03-18-Br-to-label-named-like-reg.s
align_arm_2_thumb.s
align_thumb_2_arm.s
aligned-blx.s ARM: by default don't set the Thumb bit on MachO relocated values. 2016-08-25 20:41:30 +00:00
arm11-hint-instr.s
arm_addrmode2.s
arm_addrmode3.s
arm_fixups.s
arm_instructions.s
arm-aliases.s
arm-arithmetic-aliases.s
arm-branch-errors.s ARM: validate immediate branch targets in AsmParser. 2016-07-11 22:29:37 +00:00
arm-branches.s ARM: validate immediate branch targets in AsmParser. 2016-07-11 22:29:37 +00:00
arm-elf-relocation-diagnostics.s
arm-elf-relocations.s
arm-elf-symver.s
arm-it-block.s
arm-ldrd.s
arm-load-store-multiple-deprecated.s
arm-memory-instructions.s
arm-qualifier-diagnostics.s
arm-shift-encoding.s
arm-thumb-cpus-default.s
arm-thumb-cpus.s
arm-thumb-trustzone.s [ARM] Diagnose PC-writing instructions in IT blocks 2017-02-28 10:04:36 +00:00
arm-trustzone.s
basic-arm-instructions-v8.1a.s
basic-arm-instructions-v8.s
basic-arm-instructions.s
basic-thumb2-instructions-v8.s
basic-thumb2-instructions.s [ARM] Diagnose PC-writing instructions in IT blocks 2017-02-28 10:04:36 +00:00
basic-thumb-instructions.s
big-endian-arm-fixup.s
big-endian-thumb2-fixup.s
big-endian-thumb-fixup.s
bkpt.s
bracket-darwin.s
bracket-exprs.s
branch-disassemble.s [ARM] Fix triple format in test branch disassemble test 2017-03-17 09:37:10 +00:00
cmp-immediate-fixup2.s
cmp-immediate-fixup-error2.s
cmp-immediate-fixup-error.s
cmp-immediate-fixup.s
coff-debugging-secrel.ll Emit S_COMPILE3 record once per TU rather than once per function 2016-11-02 21:30:35 +00:00
coff-file.s
coff-function-type-info.ll
coff-relocations.s [ARM] Fix triple format in test branch disassemble test 2017-03-17 09:37:10 +00:00
comment.s
complex-operands.s
coproc-diag.s
cps.s
cpu-test.s
crc32-thumb.s
crc32.s
cxx-global-constructor.ll
d16.s
data-in-code.ll [SimplifyCFG] Handle tail-sinking of more than 2 incoming branches 2016-09-01 12:58:13 +00:00
deprecated-v8.s
diagnostics-noneon.s
diagnostics.s [ARM] Diagnose ARM MOVT without :lower16: or :upper16: expression 2017-03-14 13:50:10 +00:00
directive_parsing.s [ARM][MC] Cleanup ARM Target Assembly Parser 2016-11-02 16:22:51 +00:00
directive-align.s
directive-arch_extension-crc.s
directive-arch_extension-crypto.s
directive-arch_extension-fp.s
directive-arch_extension-idiv.s
directive-arch_extension-mode-switch.s
directive-arch_extension-mp.s
directive-arch_extension-sec.s
directive-arch_extension-simd.s
directive-arch_extension-toggle.s
directive-arch_extension-unsupported.s [ARM] Improve error messages for .arch_extension directive 2016-07-26 14:24:43 +00:00
directive-arch-armv2.s
directive-arch-armv2a.s
directive-arch-armv3.s
directive-arch-armv3m.s
directive-arch-armv4.s
directive-arch-armv4t.s
directive-arch-armv5.s
directive-arch-armv5t.s
directive-arch-armv5te.s
directive-arch-armv6-m.s
directive-arch-armv6.s
directive-arch-armv6k.s
directive-arch-armv6t2.s
directive-arch-armv6z.s
directive-arch-armv7-a.s
directive-arch-armv7-m.s
directive-arch-armv7-r.s
directive-arch-armv7.s
directive-arch-armv7a.s
directive-arch-armv7m.s
directive-arch-armv7r.s
directive-arch-armv8-a.s
directive-arch-armv8.2-a.s
directive-arch-armv8a.s
directive-arch-iwmmxt2.s
directive-arch-iwmmxt.s
directive-arch-mode-switch.s
directive-arch-semantic-action.s
directive-cpu.s
directive-eabi_attribute-diagnostics.s
directive-eabi_attribute-overwrite.s
directive-eabi_attribute.s
directive-even.s
directive-fpu-diagnostics.s
directive-fpu-instrs.s
directive-fpu-multiple.s
directive-fpu-softvfp.s
directive-fpu.s
directive-literals.s
directive-object_arch-2.s Drive by typo fix 2017-01-09 21:38:14 +00:00
directive-object_arch-3.s
directive-object_arch-diagnostics.s
directive-object_arch.s Drive by typo fix 2017-01-09 21:38:14 +00:00
directive-thumb_func.s [ARM][MC] Cleanup ARM Target Assembly Parser 2016-11-02 16:22:51 +00:00
directive-tlsdescseq-diagnostics.s
directive-tlsdescseq.s
directive-type-diagnostics.s
directive-unsupported.s
directive-word-diagnostics.s
dot-req-case-insensitive.s
dot-req.s
dwarf-asm-multiple-sections-dwarf-2.s
dwarf-asm-multiple-sections.s [DWARFv5] llvm-mc support for new unit header. 2017-02-28 23:40:46 +00:00
dwarf-asm-no-code.s
dwarf-asm-nonstandard-section.s
dwarf-asm-single-section.s
dwarf-cfi-initial-state.s
eh-compact-pr0.s
eh-compact-pr1.s
eh-directive-cantunwind-diagnostics.s
eh-directive-cantunwind.s
eh-directive-fnend-diagnostics.s
eh-directive-fnstart-diagnostics.s
eh-directive-handlerdata.s
eh-directive-integrated-test.s
eh-directive-movsp-diagnostics.s
eh-directive-movsp.s
eh-directive-multiple-offsets.s
eh-directive-pad-diagnostics.s
eh-directive-pad.s
eh-directive-personality-diagnostics.s
eh-directive-personality.s
eh-directive-personalityindex-diagnostics.s
eh-directive-personalityindex.s
eh-directive-save-diagnostics.s
eh-directive-save.s
eh-directive-section-comdat.s
eh-directive-section-multiple-func.s
eh-directive-section.s
eh-directive-setfp-diagnostics.s
eh-directive-setfp.s
eh-directive-text-section-multiple-func.s
eh-directive-text-section.s
eh-directive-unwind_raw-diagnostics.s
eh-directive-unwind_raw.s
eh-directive-vsave-diagnostics.s
eh-directive-vsave.s
eh-link.s
ehabi-personality-abs.s MC: ensure that we have a section before accessing it 2016-11-22 04:32:54 +00:00
elf-eflags-eabi.s
elf-jump24-fixup.s
elf-movt.s
elf-reloc-01.s
elf-reloc-02.s
elf-reloc-03.s
elf-reloc-condcall.s
elf-thumbfunc-reloc2.s Don't pass relocation-model= to tests that don't need it. 2016-05-18 00:27:17 +00:00
elf-thumbfunc-reloc.s
elf-thumbfunc.s Fix aliases to thumbfunc-based exprs to be thumbfunc. 2017-01-19 20:04:11 +00:00
error-location-ldr-pseudo.s
error-location-post-layout.s [Assembler] Add location info to unary expressions. 2017-03-10 13:08:20 +00:00
error-location.s [Assembler] Better error messages for .org directive 2016-12-14 10:43:58 +00:00
fconst.s
fixup-cpu-mode.s
fp-armv8.s
fp-const-errors.s ARM: fix vmov.i64 immediate validity check 2016-07-14 17:04:34 +00:00
full_line_comment.s
fullfp16-neg.s
fullfp16-neon-neg.s
fullfp16-neon.s
fullfp16.s
gas-compl-copr-reg.s
hilo-16bit-relocations.s
idiv.s
implicit-it-generation.s [ARM] Implement -mimplicit-it assembler option 2016-07-26 14:19:47 +00:00
implicit-it.s [ARM] Implement -mimplicit-it assembler option 2016-07-26 14:19:47 +00:00
inline-asm-diags.ll Fix inline-asm-diags.ll on Windows, give it a triple to avoid WoA thumb confusion 2017-02-08 18:17:21 +00:00
inline-asm-srcloc.ll [Assembler] Add test for !srcloc references in assembler diags 2017-02-28 10:34:48 +00:00
inline-comments-arm.ll Add removed inline-assembly-comment test from r277146 2016-08-01 15:36:10 +00:00
inst-arm-suffixes.s
inst-constant-required.s
inst-directive-emit.s
inst-directive.s
inst-overflow.s
inst-thumb-overflow-2.s
inst-thumb-overflow.s
inst-thumb-suffixes.s
invalid-barrier.s
invalid-crc32.s
invalid-fp-armv8.s
invalid-hint-arm.s
invalid-hint-thumb.s
invalid-idiv.s
invalid-neon-v8.s
invalid-special-reg.s [ARM] Fix bash-ism in test 2017-03-01 11:11:06 +00:00
invalid-vector-index.s
ldr-pseudo-cond-darwin.s Fix some broken CHECK lines. 2017-01-22 20:28:56 +00:00
ldr-pseudo-cond.s Fix some broken CHECK lines. 2017-01-22 20:28:56 +00:00
ldr-pseudo-darwin.s Fix 24560: assembler does not share constant pool for same constants 2016-11-04 19:17:32 +00:00
ldr-pseudo-obj-errors.s [ARM] Fixup tests to take into account mov translation. NFC. 2016-05-12 21:22:37 +00:00
ldr-pseudo-parse-errors.s
ldr-pseudo-unpredictable.s [ARM] Support and tests for transform of LDR rt, = to MOV 2016-05-12 21:22:42 +00:00
ldr-pseudo-wide.s Fix 24560: assembler does not share constant pool for same constants 2016-11-04 19:17:32 +00:00
ldr-pseudo.s Fix 24560: assembler does not share constant pool for same constants 2016-11-04 19:17:32 +00:00
ldrd-strd-gnu-arm-bad-imm.s
ldrd-strd-gnu-arm.s
ldrd-strd-gnu-sp.s
ldrd-strd-gnu-thumb-bad-regs.s
ldrd-strd-gnu-thumb.s
lit.local.cfg
load-store-acquire-release-v8-thumb.s
load-store-acquire-release-v8.s
lsl-zero-errors.s [ARM] Split up lsl-zero test into two tests 2017-03-08 12:49:18 +00:00
lsl-zero.s [ARM] Split up lsl-zero test into two tests 2017-03-08 12:49:18 +00:00
ltorg-darwin.s [ARM] Fixup tests to take into account mov translation. NFC. 2016-05-12 21:22:37 +00:00
ltorg.s [ARM] Fixup tests to take into account mov translation. NFC. 2016-05-12 21:22:37 +00:00
macho-movwt.s
macho-relocs-with-addend.s
macho-word-reloc-thumb.s ARM: by default don't set the Thumb bit on MachO relocated values. 2016-08-25 20:41:30 +00:00
mapping-initial.s [Thumb] Set correct initial mapping symbol for big-endian thumb 2016-09-19 09:21:45 +00:00
mapping-within-section.s
misaligned-blx.s ARM: report an error when attempting to target a misalgined BLX 2016-05-10 21:48:48 +00:00
mode-switch.s
modified-immediate-fixup-error.s
modified-immediate-fixup.s
move-banked-regs.s
mul-v4.s
multi-section-mapping.s
negative-immediates-fail.s [ARM] [Assembler] Support negative immediates for A32, T32 and T16 2017-03-21 14:59:17 +00:00
negative-immediates-thumb1-fail.s [ARM] [Assembler] Support negative immediates for A32, T32 and T16 2017-03-21 14:59:17 +00:00
negative-immediates-thumb1.s [ARM] [Assembler] Support negative immediates for A32, T32 and T16 2017-03-21 14:59:17 +00:00
negative-immediates.s [ARM] [Assembler] Support negative immediates for A32, T32 and T16 2017-03-21 14:59:17 +00:00
neon-abs-encoding.s
neon-absdiff-encoding.s
neon-add-encoding.s
neon-bitcount-encoding.s
neon-bitwise-encoding.s
neon-cmp-encoding.s
neon-convert-encoding.s
neon-crypto.s
neon-dup-encoding.s
neon-minmax-encoding.s
neon-mov-encoding.s
neon-mov-vfp.s
neon-mul-accum-encoding.s
neon-mul-encoding.s
neon-neg-encoding.s
neon-pairwise-encoding.s
neon-reciprocal-encoding.s
neon-reverse-encoding.s
neon-satshift-encoding.s
neon-shift-encoding.s
neon-shiftaccum-encoding.s
neon-shuffle-encoding.s
neon-sub-encoding.s
neon-table-encoding.s
neon-v8.s
neon-vcvt-fp16.s
neon-vld-encoding.s
neon-vld-vst-align.s
neon-vst-encoding.s
neon-vswp.s
neont2-abs-encoding.s
neont2-absdiff-encoding.s
neont2-add-encoding.s
neont2-bitcount-encoding.s
neont2-bitwise-encoding.s
neont2-cmp-encoding.s
neont2-convert-encoding.s
neont2-dup-encoding.s
neont2-minmax-encoding.s
neont2-mov-encoding.s
neont2-mul-accum-encoding.s
neont2-mul-encoding.s
neont2-neg-encoding.s
neont2-pairwise-encoding.s
neont2-reciprocal-encoding.s
neont2-reverse-encoding.s
neont2-satshift-encoding.s
neont2-shift-encoding.s
neont2-shiftaccum-encoding.s
neont2-shuffle-encoding.s
neont2-sub-encoding.s
neont2-table-encoding.s
neont2-vld-encoding.s
neont2-vst-encoding.s
not-armv4.s [ARM] ARM mov InstAlias for MOVW lacks HasV6T2 2016-05-17 13:05:28 +00:00
obsolete-v8.s
pkhbt-archs.s ARM: move feature for Thumb2 pkhbt/pkhtb onto architectures. 2016-07-19 19:49:13 +00:00
pool.s
pr11877.s
pr22395-2.s
pr22395.s
preserve-comments-arm.s Fix handling of end-of-line preprocessor comments Attempt 2 2016-08-02 19:17:54 +00:00
quad-relocation.s [Assembler] Fix crash when assembling .quad for AArch32. 2017-01-18 15:02:54 +00:00
ras-extension.s RAS extensions are part of ARMv8.2-A. This change enables them by introducing a 2016-06-03 14:03:27 +00:00
relocated-mapping.s
simple-fp-encoding.s [ARM] remove FIXMEs and add vcmp MC test 2017-03-09 13:28:37 +00:00
single-precision-fp.s
sub-expr-imm.s [ARM] Adds test for immediate encoding 2016-07-27 12:15:26 +00:00
symbol-variants-errors.s
symbol-variants.s Add support for tlsldm assembler operator to ARM target 2016-07-19 14:15:33 +00:00
target-expressions.s
thumb1-branch-reloc.s [Thumb1] Add relocations for fixups fixup_arm_thumb_{br,bcc} 2016-09-05 08:29:15 +00:00
thumb1-relax-8m-baseline.s
thumb1-relax-adr.s
thumb1-relax-bcc.s [ARM] Incorrect relocation type for Thumb2 B<cond>.w 2016-06-07 10:34:33 +00:00
thumb1-relax-br.s
thumb1-relax-ldrlit.s
thumb1-relax.s
thumb2-b.w-encodingT4.s
thumb2-branches.s ARM: validate immediate branch targets in AsmParser. 2016-07-11 22:29:37 +00:00
thumb2-bxj-v8.s
thumb2-bxj.s
thumb2-cbn-to-next-inst.s
thumb2-diagnostics.s [ARM] Avoid using ARM instructions in Thumb mode 2017-01-31 14:35:01 +00:00
thumb2-dsp-diag.s
thumb2-exception-return-mclass.s
thumb2-ldrb-ldrh.s
thumb2-ldrd.s
thumb2-ldrexd-strexd.s
thumb2-mclass.s
thumb2-narrow-dp.ll
thumb2-pldw.s
thumb2-strd.s
thumb2be-b.w-encoding.s
thumb2be-beq.w-encoding.s
thumb2be-movt-encoding.s
thumb2be-movw-encoding.s
thumb_rewrites.s
thumb_set-diagnostics.s
thumb_set.s
thumb-branch-errors.s ARM: validate immediate branch targets in AsmParser. 2016-07-11 22:29:37 +00:00
thumb-branches.s
thumb-cb-offsets.s ARM: don't diagnose cbz/cbnz to Thumb functions. 2016-08-24 21:21:29 +00:00
thumb-cb-thumbfunc.s ARM: don't diagnose cbz/cbnz to Thumb functions. 2016-08-24 21:21:29 +00:00
thumb-diagnostics.s [ARM] Better error message for invalid flag-preserving Thumb1 insts 2016-12-06 12:59:08 +00:00
thumb-far-jump.s
thumb-fp-armv8.s
thumb-hints.s
thumb-invalid-crypto.txt
thumb-load-store-multiple.s
thumb-mov.s [ARM] Correct SP/PC handling in t2MOVr 2017-02-21 16:45:04 +00:00
thumb-movwt-reloc.s
thumb-neon-crypto.s
thumb-neon-v8.s
thumb-not-mclass.s
thumb-only-conditionals.s
thumb-shift-encoding.s
thumb-st_other.s
thumb-types.s
thumb.s
thumbv7em.s
thumbv7m.s
thumbv8m.s [ARM] Remove t2xtpk feature from tests 2017-03-09 15:14:32 +00:00
tls-directives.s Reapply: "ARM: put correct symbol index on indirect pointers in __thread_ptr."" 2016-04-26 18:29:16 +00:00
twice.ll
udf-arm-diagnostics.s
udf-arm.s
udf-thumb-2-diagnostics.s
udf-thumb-2.s
udf-thumb-diagnostics.s
udf-thumb.s
unpred-control-flow-in-it-block.s [ARM] Diagnose PC-writing instructions in IT blocks 2017-02-28 10:04:36 +00:00
unwind-stack-diagnostics.s
v7k-dsp.s
v8_IT_manual.s
variant-diagnostics.s
vfp4.s
vfp-aliases-diagnostics.s
vfp-aliases.s
virtexts-arm.s
virtexts-thumb.s
vmov-vmvn-byte-replicate.s
vmov-vmvn-illegal-cases.s
vorr-vbic-illegal-cases.s
vpush-vpop.s