From b8958b031ec5163261f490f131780c5dc3d823d6 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 8 Dec 2010 01:57:09 +0000 Subject: [PATCH] Add support for loading from a constant pool. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121226 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/ELFObjectWriter.cpp | 1 + lib/Target/ARM/ARMAsmBackend.cpp | 11 +++++++++-- lib/Target/ARM/ARMCodeEmitter.cpp | 2 ++ lib/Target/ARM/ARMFixupKinds.h | 3 +++ lib/Target/ARM/ARMInstrThumb.td | 24 +++++++++++++++++++----- lib/Target/ARM/ARMMCCodeEmitter.cpp | 30 +++++++++++++++++++++++++++--- utils/TableGen/EDEmitter.cpp | 2 ++ 7 files changed, 63 insertions(+), 10 deletions(-) diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index b51e508ab26..c9e8074c413 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -1549,6 +1549,7 @@ unsigned ARMELFObjectWriter::GetRelocType(const MCValue &Target, case ARM::fixup_arm_pcrel_10: case ARM::fixup_arm_adr_pcrel_12: case ARM::fixup_arm_thumb_bl: + case ARM::fixup_arm_thumb_cp: assert(0 && "Unimplemented"); break; case ARM::fixup_arm_branch: return ELF::R_ARM_CALL; break; diff --git a/lib/Target/ARM/ARMAsmBackend.cpp b/lib/Target/ARM/ARMAsmBackend.cpp index 90b181e2cb7..f5ac33ab236 100644 --- a/lib/Target/ARM/ARMAsmBackend.cpp +++ b/lib/Target/ARM/ARMAsmBackend.cpp @@ -138,6 +138,9 @@ static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) { Binary = ((Binary & 0x7ff) << 16) | (Binary >> 11); return Binary; } + case ARM::fixup_arm_thumb_cp: + // Offset by 4, and don't encode the low two bits. + return ((Value - 4) >> 2) & 0xff; case ARM::fixup_t2_pcrel_10: case ARM::fixup_arm_pcrel_10: { // Offset by 8 just as above. @@ -243,13 +246,17 @@ static unsigned getFixupKindNumBytes(unsigned Kind) { switch (Kind) { default: llvm_unreachable("Unknown fixup kind!"); - case FK_Data_4: - return 4; + + case ARM::fixup_arm_thumb_cp: + return 1; + case ARM::fixup_arm_ldst_pcrel_12: case ARM::fixup_arm_pcrel_10: case ARM::fixup_arm_adr_pcrel_12: case ARM::fixup_arm_branch: return 3; + + case FK_Data_4: case ARM::fixup_t2_pcrel_10: case ARM::fixup_arm_thumb_bl: return 4; diff --git a/lib/Target/ARM/ARMCodeEmitter.cpp b/lib/Target/ARM/ARMCodeEmitter.cpp index 2e2570cc4ba..4dd1524ba3c 100644 --- a/lib/Target/ARM/ARMCodeEmitter.cpp +++ b/lib/Target/ARM/ARMCodeEmitter.cpp @@ -255,6 +255,8 @@ namespace { const { return 0; } uint32_t getAddrModeS1OpValue(const MachineInstr &MI, unsigned Op) const { return 0; } + uint32_t getAddrModePCOpValue(const MachineInstr &MI, unsigned Op) + const { return 0; } uint32_t getAddrMode5OpValue(const MachineInstr &MI, unsigned Op) const { // {17-13} = reg // {12} = (U)nsigned (add == '1', sub == '0') diff --git a/lib/Target/ARM/ARMFixupKinds.h b/lib/Target/ARM/ARMFixupKinds.h index 0136e0c004f..b05e1164838 100644 --- a/lib/Target/ARM/ARMFixupKinds.h +++ b/lib/Target/ARM/ARMFixupKinds.h @@ -34,6 +34,9 @@ enum Fixups { // fixup_arm_thumb_bl - Fixup for Thumb BL/BLX instructions. fixup_arm_thumb_bl, + // fixup_arm_thumb_cp - Fixup for Thumb load/store from constant pool instrs. + fixup_arm_thumb_cp, + // The next two are for the movt/movw pair // the 16bit imm field are split into imm{15-12} and imm{11-0} // Fixme: We need new ones for Thumb. diff --git a/lib/Target/ARM/ARMInstrThumb.td b/lib/Target/ARM/ARMInstrThumb.td index c17e04276f3..cfe4e39c641 100644 --- a/lib/Target/ARM/ARMInstrThumb.td +++ b/lib/Target/ARM/ARMInstrThumb.td @@ -134,6 +134,13 @@ def t_addrmode_sp : Operand, let ParserMatchClass = MemModeThumbAsmOperand; } +// t_addrmode_pc :=