From db2950fa29d80a325e737bf8f65dbb23f1b571c6 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 21 Jun 2016 14:21:53 +0000 Subject: [PATCH] Define a isPositionIndependent helper for ARMAsmPrinter. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273261 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMAsmPrinter.cpp | 8 ++++++-- lib/Target/ARM/ARMAsmPrinter.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp index 1c4148ffd98..25d2ec95432 100644 --- a/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/ARMAsmPrinter.cpp @@ -613,6 +613,10 @@ static ARMBuildAttrs::CPUArch getArchForCPU(StringRef CPU, return ARMBuildAttrs::v4; } +bool ARMAsmPrinter::isPositionIndependent() const { + return TM.getRelocationModel() == Reloc::PIC_; +} + void ARMAsmPrinter::emitAttributes() { MCTargetStreamer &TS = *OutStreamer->getTargetStreamer(); ARMTargetStreamer &ATS = static_cast(TS); @@ -724,7 +728,7 @@ void ARMAsmPrinter::emitAttributes() { ATS.emitFPU(ARM::FK_VFPV2); } - if (TM.getRelocationModel() == Reloc::PIC_) { + if (isPositionIndependent()) { // PIC specific attributes. ATS.emitAttribute(ARMBuildAttrs::ABI_PCS_RW_data, ARMBuildAttrs::AddressRWPCRel); @@ -1036,7 +1040,7 @@ void ARMAsmPrinter::EmitJumpTableAddrs(const MachineInstr *MI) { // .word (LBB1 - LJTI_0_0) const MCExpr *Expr = MCSymbolRefExpr::create(MBB->getSymbol(), OutContext); - if (TM.getRelocationModel() == Reloc::PIC_) + if (isPositionIndependent()) Expr = MCBinaryExpr::createSub(Expr, MCSymbolRefExpr::create(JTISymbol, OutContext), OutContext); diff --git a/lib/Target/ARM/ARMAsmPrinter.h b/lib/Target/ARM/ARMAsmPrinter.h index ed7be2de51c..d38669a6634 100644 --- a/lib/Target/ARM/ARMAsmPrinter.h +++ b/lib/Target/ARM/ARMAsmPrinter.h @@ -95,6 +95,8 @@ public: bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp); private: + bool isPositionIndependent() const; + // Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile() void emitAttributes(); -- 2.50.1