From 02265382929b0275d7b7b334eab5e2fd34e1b9fe Mon Sep 17 00:00:00 2001 From: Mihai Popa Date: Mon, 22 Jul 2013 15:49:36 +0000 Subject: [PATCH] This adds range checking for "ldr Rn, [pc, #imm]" Thumb instructions. With this patch: 1. ldr.n is recognized as mnemonic for the short encoding 2. ldr.w is recognized as menmonic for the long encoding 3. ldr will map to either short or long encodings depending on the size of the offset git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186831 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMInstrThumb.td | 43 +++++++++---------- lib/Target/ARM/ARMInstrThumb2.td | 2 +- lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 40 +++++++++++++++++ lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp | 2 +- test/CodeGen/ARM/fast-isel-pic.ll | 8 ++-- test/CodeGen/ARM/indirectbr.ll | 6 +-- test/CodeGen/ARM/load-global.ll | 2 +- test/CodeGen/ARM/machine-licm.ll | 2 +- test/CodeGen/Thumb/large-stack.ll | 6 +-- test/MC/ARM/basic-thumb2-instructions.s | 21 ++++++++- 10 files changed, 93 insertions(+), 39 deletions(-) diff --git a/lib/Target/ARM/ARMInstrThumb.td b/lib/Target/ARM/ARMInstrThumb.td index a0edaba04e8..e7218c66586 100644 --- a/lib/Target/ARM/ARMInstrThumb.td +++ b/lib/Target/ARM/ARMInstrThumb.td @@ -100,6 +100,13 @@ class OperandUnsignedOffset_b8s2 : AsmOperandClass { def UnsignedOffset_b8s2 : OperandUnsignedOffset_b8s2; +// thumb style PC relative operand. signed, 8 bits magnitude, +// two bits shift. can be represented as either [pc, #imm], #imm, +// or relocatable expression... +def ThumbMemPC : AsmOperandClass { + let Name = "ThumbMemPC"; +} + let OperandType = "OPERAND_PCREL" in { def t_brtarget : Operand { let EncoderMethod = "getThumbBRTargetOpValue"; @@ -132,6 +139,15 @@ def t_blxtarget : Operand { let EncoderMethod = "getThumbBLXTargetOpValue"; let DecoderMethod = "DecodeThumbBLXOffset"; } + +// t_addrmode_pc :=