[ARM] Fix triple format in test branch disassemble test

Fixing triple format in the tests added for the branch label fix for Thumb
Targets. Also recommitting previously approved patch, see
https://reviews.llvm.org/D30943.

Reviewed by: samparker

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

llvm-svn: 298056
This commit is contained in:
Andre Vieira 2017-03-17 09:37:10 +00:00
parent d74f31bf13
commit 913ffeb5ba
3 changed files with 48 additions and 11 deletions

View File

@ -260,18 +260,37 @@ public:
return false;
int64_t Imm = Inst.getOperand(0).getImm();
// FIXME: This is not right for thumb.
Target = Addr+Imm+8; // In ARM mode the PC is always off by 8 bytes.
return true;
}
};
class ThumbMCInstrAnalysis : public ARMMCInstrAnalysis {
public:
ThumbMCInstrAnalysis(const MCInstrInfo *Info) : ARMMCInstrAnalysis(Info) {}
bool evaluateBranch(const MCInst &Inst, uint64_t Addr,
uint64_t Size, uint64_t &Target) const override {
// We only handle PCRel branches for now.
if (Info->get(Inst.getOpcode()).OpInfo[0].OperandType!=MCOI::OPERAND_PCREL)
return false;
int64_t Imm = Inst.getOperand(0).getImm();
Target = Addr+Imm+4; // In Thumb mode the PC is always off by 4 bytes.
return true;
}
};
}
static MCInstrAnalysis *createARMMCInstrAnalysis(const MCInstrInfo *Info) {
return new ARMMCInstrAnalysis(Info);
}
static MCInstrAnalysis *createThumbMCInstrAnalysis(const MCInstrInfo *Info) {
return new ThumbMCInstrAnalysis(Info);
}
// Force static initialization.
extern "C" void LLVMInitializeARMTargetMC() {
for (Target *T : {&getTheARMLETarget(), &getTheARMBETarget(),
@ -289,9 +308,6 @@ extern "C" void LLVMInitializeARMTargetMC() {
TargetRegistry::RegisterMCSubtargetInfo(*T,
ARM_MC::createARMMCSubtargetInfo);
// Register the MC instruction analyzer.
TargetRegistry::RegisterMCInstrAnalysis(*T, createARMMCInstrAnalysis);
TargetRegistry::RegisterELFStreamer(*T, createELFStreamer);
TargetRegistry::RegisterCOFFStreamer(*T, createARMWinCOFFStreamer);
TargetRegistry::RegisterMachOStreamer(*T, createARMMachOStreamer);
@ -313,6 +329,12 @@ extern "C" void LLVMInitializeARMTargetMC() {
TargetRegistry::RegisterMCRelocationInfo(*T, createARMMCRelocationInfo);
}
// Register the MC instruction analyzer.
for (Target *T : {&getTheARMLETarget(), &getTheARMBETarget()})
TargetRegistry::RegisterMCInstrAnalysis(*T, createARMMCInstrAnalysis);
for (Target *T : {&getTheThumbLETarget(), &getTheThumbBETarget()})
TargetRegistry::RegisterMCInstrAnalysis(*T, createThumbMCInstrAnalysis);
// Register the MC Code Emitter
for (Target *T : {&getTheARMLETarget(), &getTheThumbLETarget()})
TargetRegistry::RegisterMCCodeEmitter(*T, createARMLEMCCodeEmitter);

View File

@ -0,0 +1,15 @@
@ RUN: llvm-mc -mcpu=cortex-a9 -triple armv7-arm-none-eabi -filetype obj -o - %s \
@ RUN: | llvm-objdump -mcpu=cortex-a9 -triple armv7-arm-none-eabi -d - \
@ RUN: | FileCheck %s -check-prefix CHECK-ARM
@ RUN: llvm-mc -mcpu=cortex-m3 -triple thumbv7m-arm-none-eabi -filetype obj -o - %s \
@ RUN: | llvm-objdump -mcpu=cortex-m3 -triple thumbv7m-arm-none-eabi -d - \
@ RUN: | FileCheck %s -check-prefix CHECK-THUMB
b.w .Lbranch
@ CHECK-ARM: b #4 <$a.0+0xC>
@ CHECK-THUMB: b.w #8 <$t.0+0xC>
adds r0, r1, #42
adds r1, r2, #42
.Lbranch:
movs r2, r3

View File

@ -14,21 +14,21 @@
branch24t:
b target
@ CHECK-ENCODING-LABEL: branch24t
@ CHECK-ENCODING-LABEL: branch24t:
@ CHECK-ENCODING-NEXT: b.w #0
.thumb_func
branch20t:
bcc target
@ CHECK-ENCODING-LABEL: branch20t
@ CHECK-ENCODING-LABEL: branch20t:
@ CHECK-ENCODING-NEXT: blo.w #0
.thumb_func
blx23t:
bl target
@ CHECK-ENCODING-LABEL: blx23t
@ CHECK-ENCODING-LABEL: blx23t:
@ CHECK-ENCODING-NEXT: bl #0
.thumb_func
@ -37,7 +37,7 @@ mov32t:
movt r0, :upper16:target
blx r0
@ CHECK-ENCODING-LABEL: mov32t
@ CHECK-ENCODING-LABEL: mov32t:
@ CHECK-ENCODING-NEXT: movw r0, #0
@ CHECK-ENCODING-NEXT: movt r0, #0
@ CHECK-ENCODING-NEXT: blx r0
@ -50,7 +50,7 @@ addr32:
.Laddr32:
.long target
@ CHECK-ENCODING-LABEL: addr32
@ CHECK-ENCODING-LABEL: addr32:
@ CHECK-ENCODING-NEXT: ldr r0, [pc, #4]
@ CHECK-ENCODING-NEXT: bx r0
@ CHECK-ENCODING-NEXT: trap
@ -65,7 +65,7 @@ addr32nb:
.Laddr32nb:
.long target(imgrel)
@ CHECK-ENCODING-LABEL: addr32nb
@ CHECK-ENCODING-LABEL: addr32nb:
@ CHECK-ENCODING-NEXT: ldr.w r0, [pc, #4]
@ CHECK-ENCODING-NEXT: bx r0
@ CHECK-ENCODING-NEXT: trap
@ -80,7 +80,7 @@ secrel:
.Lsecrel:
.long target(secrel32)
@ CHECK-ENCODING-LABEL: secrel
@ CHECK-ENCODING-LABEL: secrel:
@ CHECK-ENCODING-NEXT: ldr.w r0, [pc, #4]
@ CHECK-ENCODING-NEXT: bx r0
@ CHECK-ENCODING-NEXT: trap