summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Mips
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/Mips')
-rw-r--r--llvm/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp14
-rw-r--r--llvm/lib/Target/Mips/Mips.h2
-rw-r--r--llvm/lib/Target/Mips/MipsTargetMachine.cpp51
-rw-r--r--llvm/lib/Target/Mips/MipsTargetMachine.h9
4 files changed, 49 insertions, 27 deletions
diff --git a/llvm/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
index 501dc6a7aba..719c258647c 100644
--- a/llvm/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
+++ b/llvm/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
@@ -33,7 +33,6 @@
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
-#include "llvm/Target/TargetRegistry.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Mangler.h"
#include "llvm/ADT/Statistic.h"
@@ -52,7 +51,7 @@ namespace {
class VISIBILITY_HIDDEN MipsAsmPrinter : public AsmPrinter {
const MipsSubtarget *Subtarget;
public:
- explicit MipsAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
+ explicit MipsAsmPrinter(formatted_raw_ostream &O, MipsTargetMachine &TM,
const TargetAsmInfo *T, bool V)
: AsmPrinter(O, TM, T, V) {
Subtarget = &TM.getSubtarget<MipsSubtarget>();
@@ -93,7 +92,7 @@ namespace {
/// using the given target machine description. This should work
/// regardless of whether the function is in SSA form.
FunctionPass *llvm::createMipsCodePrinterPass(formatted_raw_ostream &o,
- TargetMachine &tm,
+ MipsTargetMachine &tm,
bool verbose) {
return new MipsAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
}
@@ -585,11 +584,4 @@ namespace {
}
// Force static initialization.
-extern "C" void LLVMInitializeMipsAsmPrinter() {
- extern Target TheMipsTarget;
- TargetRegistry::RegisterAsmPrinter(TheMipsTarget, createMipsCodePrinterPass);
-
- extern Target TheMipselTarget;
- TargetRegistry::RegisterAsmPrinter(TheMipselTarget,
- createMipsCodePrinterPass);
-}
+extern "C" void LLVMInitializeMipsAsmPrinter() { }
diff --git a/llvm/lib/Target/Mips/Mips.h b/llvm/lib/Target/Mips/Mips.h
index 1ff34fbcc76..c1d6fdda513 100644
--- a/llvm/lib/Target/Mips/Mips.h
+++ b/llvm/lib/Target/Mips/Mips.h
@@ -26,7 +26,7 @@ namespace llvm {
FunctionPass *createMipsISelDag(MipsTargetMachine &TM);
FunctionPass *createMipsDelaySlotFillerPass(MipsTargetMachine &TM);
FunctionPass *createMipsCodePrinterPass(formatted_raw_ostream &OS,
- TargetMachine &TM,
+ MipsTargetMachine &TM,
bool Verbose);
} // end namespace llvm;
diff --git a/llvm/lib/Target/Mips/MipsTargetMachine.cpp b/llvm/lib/Target/Mips/MipsTargetMachine.cpp
index 3c2693bf16d..1e6add4a545 100644
--- a/llvm/lib/Target/Mips/MipsTargetMachine.cpp
+++ b/llvm/lib/Target/Mips/MipsTargetMachine.cpp
@@ -28,12 +28,8 @@ extern "C" int MipsTargetMachineModule;
int MipsTargetMachineModule = 0;
// Register the target.
-extern Target TheMipsTarget;
-static RegisterTarget<MipsTargetMachine> X(TheMipsTarget, "mips", "Mips");
-
-extern Target TheMipselTarget;
-static RegisterTarget<MipselTargetMachine> Y(TheMipselTarget, "mipsel",
- "Mipsel");
+static RegisterTarget<MipsTargetMachine> X("mips", "Mips");
+static RegisterTarget<MipselTargetMachine> Y("mipsel", "Mipsel");
MipsTargetMachine::AsmPrinterCtorFn MipsTargetMachine::AsmPrinterCtor = 0;
@@ -55,9 +51,7 @@ createTargetAsmInfo() const
// an easier handling.
// Using CodeModel::Large enables different CALL behavior.
MipsTargetMachine::
-MipsTargetMachine(const Target &T, const Module &M, const std::string &FS,
- bool isLittle=false):
- LLVMTargetMachine(T),
+MipsTargetMachine(const Module &M, const std::string &FS, bool isLittle=false):
Subtarget(*this, M, FS, isLittle),
DataLayout(isLittle ? std::string("e-p:32:32:32-i8:8:32-i16:16:32") :
std::string("E-p:32:32:32-i8:8:32-i16:16:32")),
@@ -76,8 +70,43 @@ MipsTargetMachine(const Target &T, const Module &M, const std::string &FS,
}
MipselTargetMachine::
-MipselTargetMachine(const Target &T, const Module &M, const std::string &FS) :
- MipsTargetMachine(T, M, FS, true) {}
+MipselTargetMachine(const Module &M, const std::string &FS) :
+ MipsTargetMachine(M, FS, true) {}
+
+// return 0 and must specify -march to gen MIPS code.
+unsigned MipsTargetMachine::
+getModuleMatchQuality(const Module &M)
+{
+ // We strongly match "mips*-*".
+ std::string TT = M.getTargetTriple();
+ if (TT.size() >= 5 && std::string(TT.begin(), TT.begin()+5) == "mips-")
+ return 20;
+
+ if (TT.size() >= 13 && std::string(TT.begin(),
+ TT.begin()+13) == "mipsallegrex-")
+ return 20;
+
+ return 0;
+}
+
+// return 0 and must specify -march to gen MIPSEL code.
+unsigned MipselTargetMachine::
+getModuleMatchQuality(const Module &M)
+{
+ // We strongly match "mips*el-*".
+ std::string TT = M.getTargetTriple();
+ if (TT.size() >= 7 && std::string(TT.begin(), TT.begin()+7) == "mipsel-")
+ return 20;
+
+ if (TT.size() >= 15 && std::string(TT.begin(),
+ TT.begin()+15) == "mipsallegrexel-")
+ return 20;
+
+ if (TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "psp")
+ return 20;
+
+ return 0;
+}
// Install an instruction selector pass using
// the ISelDag to gen Mips code.
diff --git a/llvm/lib/Target/Mips/MipsTargetMachine.h b/llvm/lib/Target/Mips/MipsTargetMachine.h
index 6e2562a312e..7dd8d2befa0 100644
--- a/llvm/lib/Target/Mips/MipsTargetMachine.h
+++ b/llvm/lib/Target/Mips/MipsTargetMachine.h
@@ -38,13 +38,12 @@ namespace llvm {
// asmprinter set this functions to ctor pointer at startup time if they are
// linked in.
typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
- TargetMachine &tm,
+ MipsTargetMachine &tm,
bool verbose);
static AsmPrinterCtorFn AsmPrinterCtor;
public:
- MipsTargetMachine(const Target &T, const Module &M, const std::string &FS,
- bool isLittle);
+ MipsTargetMachine(const Module &M, const std::string &FS, bool isLittle);
static void registerAsmPrinter(AsmPrinterCtorFn F) {
AsmPrinterCtor = F;
@@ -67,6 +66,8 @@ namespace llvm {
return const_cast<MipsTargetLowering*>(&TLInfo);
}
+ static unsigned getModuleMatchQuality(const Module &M);
+
// Pass Pipeline Configuration
virtual bool addInstSelector(PassManagerBase &PM,
CodeGenOpt::Level OptLevel);
@@ -81,7 +82,7 @@ namespace llvm {
///
class MipselTargetMachine : public MipsTargetMachine {
public:
- MipselTargetMachine(const Target &T, const Module &M, const std::string &FS);
+ MipselTargetMachine(const Module &M, const std::string &FS);
static unsigned getModuleMatchQuality(const Module &M);
};
OpenPOWER on IntegriCloud