summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2015-01-06 01:12:30 +0000
committerEric Christopher <echristo@gmail.com>2015-01-06 01:12:30 +0000
commit1abeb7758805af45433af40c449dae22bc98174f (patch)
tree6e717a9923ac6500225b270bf5830033af6b99df
parentbce877c84c19efbff64500c227afd40087276070 (diff)
Rewrite the Mips16HardFloat pass to avoid using the Subtarget.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225231 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/Mips/Mips16HardFloat.cpp24
-rw-r--r--lib/Target/Mips/Mips16HardFloat.h16
-rw-r--r--lib/Target/Mips/MipsFastISel.cpp2
-rw-r--r--lib/Target/Mips/MipsTargetMachine.h2
4 files changed, 18 insertions, 26 deletions
diff --git a/lib/Target/Mips/Mips16HardFloat.cpp b/lib/Target/Mips/Mips16HardFloat.cpp
index ecdf2793fe7..32dc90af2ef 100644
--- a/lib/Target/Mips/Mips16HardFloat.cpp
+++ b/lib/Target/Mips/Mips16HardFloat.cpp
@@ -247,12 +247,12 @@ static void swapFPIntParams
// Having called needsFPHelperFromSig
//
static void assureFPCallStub(Function &F, Module *M,
- const MipsSubtarget &Subtarget) {
+ const MipsTargetMachine &TM) {
// for now we only need them for static relocation
- if (Subtarget.getRelocationModel() == Reloc::PIC_)
+ if (TM.getRelocationModel() == Reloc::PIC_)
return;
LLVMContext &Context = M->getContext();
- bool LE = Subtarget.isLittle();
+ bool LE = TM.isLittleEndian();
std::string Name = F.getName();
std::string SectionName = ".mips16.call.fp." + Name;
std::string StubName = "__call_stub_fp_" + Name;
@@ -362,8 +362,8 @@ static bool isIntrinsicInline(Function *F) {
// Returns of float, double and complex need to be handled with a helper
// function.
//
-static bool fixupFPReturnAndCall
- (Function &F, Module *M, const MipsSubtarget &Subtarget) {
+static bool fixupFPReturnAndCall(Function &F, Module *M,
+ const MipsTargetMachine &TM) {
bool Modified = false;
LLVMContext &C = M->getContext();
Type *MyVoid = Type::getVoidTy(C);
@@ -426,9 +426,9 @@ static bool fixupFPReturnAndCall
Modified=true;
F.addFnAttr("saveS2");
}
- if (Subtarget.getRelocationModel() != Reloc::PIC_ ) {
+ if (TM.getRelocationModel() != Reloc::PIC_ ) {
if (needsFPHelperFromSig(*F_)) {
- assureFPCallStub(*F_, M, Subtarget);
+ assureFPCallStub(*F_, M, TM);
Modified=true;
}
}
@@ -439,9 +439,9 @@ static bool fixupFPReturnAndCall
}
static void createFPFnStub(Function *F, Module *M, FPParamVariant PV,
- const MipsSubtarget &Subtarget ) {
- bool PicMode = Subtarget.getRelocationModel() == Reloc::PIC_;
- bool LE = Subtarget.isLittle();
+ const MipsTargetMachine &TM) {
+ bool PicMode = TM.getRelocationModel() == Reloc::PIC_;
+ bool LE = TM.isLittleEndian();
LLVMContext &Context = M->getContext();
std::string Name = F->getName();
std::string SectionName = ".mips16.fn." + Name;
@@ -520,11 +520,11 @@ bool Mips16HardFloat::runOnModule(Module &M) {
}
if (F->isDeclaration() || F->hasFnAttribute("mips16_fp_stub") ||
F->hasFnAttribute("nomips16")) continue;
- Modified |= fixupFPReturnAndCall(*F, &M, Subtarget);
+ Modified |= fixupFPReturnAndCall(*F, &M, TM);
FPParamVariant V = whichFPParamVariantNeeded(*F);
if (V != NoSig) {
Modified = true;
- createFPFnStub(F, &M, V, Subtarget);
+ createFPFnStub(F, &M, V, TM);
}
}
return Modified;
diff --git a/lib/Target/Mips/Mips16HardFloat.h b/lib/Target/Mips/Mips16HardFloat.h
index 19b7bf23e7b..586cc252353 100644
--- a/lib/Target/Mips/Mips16HardFloat.h
+++ b/lib/Target/Mips/Mips16HardFloat.h
@@ -25,26 +25,16 @@ using namespace llvm;
namespace llvm {
class Mips16HardFloat : public ModulePass {
-
public:
static char ID;
- Mips16HardFloat(MipsTargetMachine &TM_) : ModulePass(ID),
- TM(TM_), Subtarget(TM.getSubtarget<MipsSubtarget>()) {
- }
-
- const char *getPassName() const override {
- return "MIPS16 Hard Float Pass";
- }
+ Mips16HardFloat(MipsTargetMachine &TM_) : ModulePass(ID), TM(TM_) {}
+ const char *getPassName() const override { return "MIPS16 Hard Float Pass"; }
bool runOnModule(Module &M) override;
protected:
- /// Keep a pointer to the MipsSubtarget around so that we can make the right
- /// decision when generating code for different targets.
- const TargetMachine &TM;
- const MipsSubtarget &Subtarget;
-
+ const MipsTargetMachine &TM;
};
ModulePass *createMips16HardFloat(MipsTargetMachine &TM);
diff --git a/lib/Target/Mips/MipsFastISel.cpp b/lib/Target/Mips/MipsFastISel.cpp
index ff4814427e8..2412bc8dfbe 100644
--- a/lib/Target/Mips/MipsFastISel.cpp
+++ b/lib/Target/Mips/MipsFastISel.cpp
@@ -162,7 +162,7 @@ public:
Subtarget(&TM.getSubtarget<MipsSubtarget>()) {
MFI = funcInfo.MF->getInfo<MipsFunctionInfo>();
Context = &funcInfo.Fn->getContext();
- TargetSupported = ((Subtarget->getRelocationModel() == Reloc::PIC_) &&
+ TargetSupported = ((TM.getRelocationModel() == Reloc::PIC_) &&
((Subtarget->hasMips32r2() || Subtarget->hasMips32()) &&
(Subtarget->isABI_O32())));
UnsupportedFPMode = Subtarget->isFP64bit();
diff --git a/lib/Target/Mips/MipsTargetMachine.h b/lib/Target/Mips/MipsTargetMachine.h
index 1349f82c3e0..4b097a2cf02 100644
--- a/lib/Target/Mips/MipsTargetMachine.h
+++ b/lib/Target/Mips/MipsTargetMachine.h
@@ -59,6 +59,8 @@ public:
TargetLoweringObjectFile *getObjFileLowering() const override {
return TLOF.get();
}
+
+ bool isLittleEndian() const { return isLittle; }
};
/// MipsebTargetMachine - Mips32/64 big endian target machine.