aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Target/TargetMachine.h21
-rw-r--r--include/llvm/Target/TargetMachineRegistry.h47
-rw-r--r--include/llvm/Target/TargetRegistry.h16
-rw-r--r--include/llvm/Target/TargetSelect.h4
-rw-r--r--lib/ExecutionEngine/JIT/TargetSelect.cpp13
-rw-r--r--lib/Support/TargetRegistry.cpp12
-rw-r--r--lib/Target/ARM/ARM.h2
-rw-r--r--lib/Target/ARM/ARMTargetMachine.cpp78
-rw-r--r--lib/Target/ARM/ARMTargetMachine.h12
-rw-r--r--lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp9
-rw-r--r--lib/Target/Alpha/AlphaTargetMachine.cpp37
-rw-r--r--lib/Target/Alpha/AlphaTargetMachine.h5
-rw-r--r--lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp11
-rw-r--r--lib/Target/CBackend/CBackend.cpp22
-rw-r--r--lib/Target/CBackend/CTargetMachine.h8
-rw-r--r--lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp14
-rw-r--r--lib/Target/CellSPU/SPU.h2
-rw-r--r--lib/Target/CellSPU/SPUTargetMachine.cpp23
-rw-r--r--lib/Target/CellSPU/SPUTargetMachine.h10
-rw-r--r--lib/Target/CppBackend/CPPBackend.cpp3
-rw-r--r--lib/Target/CppBackend/CPPTargetMachine.h7
-rw-r--r--lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp8
-rw-r--r--lib/Target/IA64/IA64.h2
-rw-r--r--lib/Target/IA64/IA64TargetMachine.cpp35
-rw-r--r--lib/Target/IA64/IA64TargetMachine.h6
-rw-r--r--lib/Target/MSIL/MSILWriter.cpp7
-rw-r--r--lib/Target/MSP430/MSP430TargetMachine.cpp18
-rw-r--r--lib/Target/MSP430/MSP430TargetMachine.h3
-rw-r--r--lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp14
-rw-r--r--lib/Target/Mips/Mips.h2
-rw-r--r--lib/Target/Mips/MipsTargetMachine.cpp51
-rw-r--r--lib/Target/Mips/MipsTargetMachine.h9
-rw-r--r--lib/Target/PIC16/PIC16TargetMachine.cpp19
-rw-r--r--lib/Target/PIC16/PIC16TargetMachine.h4
-rw-r--r--lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp15
-rw-r--r--lib/Target/PowerPC/PPC.h2
-rw-r--r--lib/Target/PowerPC/PPCTargetMachine.cpp75
-rw-r--r--lib/Target/PowerPC/PPCTargetMachine.h15
-rw-r--r--lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp7
-rw-r--r--lib/Target/Sparc/SparcTargetMachine.cpp35
-rw-r--r--lib/Target/Sparc/SparcTargetMachine.h3
-rw-r--r--lib/Target/TargetMachine.cpp4
-rw-r--r--lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h2
-rw-r--r--lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp11
-rw-r--r--lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h2
-rw-r--r--lib/Target/X86/X86.h2
-rw-r--r--lib/Target/X86/X86TargetMachine.cpp86
-rw-r--r--lib/Target/X86/X86TargetMachine.h12
-rw-r--r--lib/Target/XCore/XCoreTargetMachine.cpp18
-rw-r--r--lib/Target/XCore/XCoreTargetMachine.h3
-rw-r--r--tools/llc/llc.cpp23
-rw-r--r--tools/lto/LTOCodeGenerator.cpp8
-rw-r--r--tools/lto/LTOModule.cpp6
53 files changed, 557 insertions, 306 deletions
diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h
index 5ac1d69941..ce293d5114 100644
--- a/include/llvm/Target/TargetMachine.h
+++ b/include/llvm/Target/TargetMachine.h
@@ -19,7 +19,6 @@
namespace llvm {
-class Target;
class TargetAsmInfo;
class TargetData;
class TargetSubtarget;
@@ -100,14 +99,11 @@ class TargetMachine {
TargetMachine(const TargetMachine &); // DO NOT IMPLEMENT
void operator=(const TargetMachine &); // DO NOT IMPLEMENT
protected: // Can only create subclasses.
- TargetMachine(const Target &);
+ TargetMachine();
/// getSubtargetImpl - virtual method implemented by subclasses that returns
/// a reference to that target's TargetSubtarget-derived member variable.
virtual const TargetSubtarget *getSubtargetImpl() const { return 0; }
-
- /// TheTarget - The Target that this machine was created for.
- const Target &TheTarget;
/// AsmInfo - Contains target specific asm information.
///
@@ -120,7 +116,18 @@ protected: // Can only create subclasses.
public:
virtual ~TargetMachine();
- const Target &getTarget() const { return TheTarget; }
+ /// getModuleMatchQuality - This static method should be implemented by
+ /// targets to indicate how closely they match the specified module. This is
+ /// used by the LLC tool to determine which target to use when an explicit
+ /// -march option is not specified. If a target returns zero, it will never
+ /// be chosen without an explicit -march option.
+ static unsigned getModuleMatchQuality(const Module &) { return 0; }
+
+ /// getJITMatchQuality - This static method should be implemented by targets
+ /// that provide JIT capabilities to indicate how suitable they are for
+ /// execution on the current host. If a value of 0 is returned, the target
+ /// will not be used unless an explicit -march option is used.
+ static unsigned getJITMatchQuality() { return 0; }
// Interfaces to the major aspects of target machine information:
// -- Instruction opcode and operand information
@@ -301,7 +308,7 @@ public:
///
class LLVMTargetMachine : public TargetMachine {
protected: // Can only create subclasses.
- LLVMTargetMachine(const Target &T) : TargetMachine(T) { }
+ LLVMTargetMachine() { }
/// addCommonCodeGenPasses - Add standard LLVM codegen passes used for
/// both emitting to assembly files or machine code output.
diff --git a/include/llvm/Target/TargetMachineRegistry.h b/include/llvm/Target/TargetMachineRegistry.h
index 6b78a58ab0..b7ea448b20 100644
--- a/include/llvm/Target/TargetMachineRegistry.h
+++ b/include/llvm/Target/TargetMachineRegistry.h
@@ -19,21 +19,25 @@
#include "llvm/Module.h"
#include "llvm/Support/Registry.h"
-#include "llvm/Target/TargetRegistry.h"
namespace llvm {
class Module;
- class Target;
class TargetMachine;
struct TargetMachineRegistryEntry {
- const Target &TheTarget;
const char *Name;
const char *ShortDesc;
+ TargetMachine *(*CtorFn)(const Module &, const std::string &);
+ unsigned (*ModuleMatchQualityFn)(const Module &M);
+ unsigned (*JITMatchQualityFn)();
public:
- TargetMachineRegistryEntry(const Target &T, const char *N, const char *SD)
- : TheTarget(T), Name(N), ShortDesc(SD) {}
+ TargetMachineRegistryEntry(const char *N, const char *SD,
+ TargetMachine *(*CF)(const Module &, const std::string &),
+ unsigned (*MMF)(const Module &M),
+ unsigned (*JMF)())
+ : Name(N), ShortDesc(SD), CtorFn(CF), ModuleMatchQualityFn(MMF),
+ JITMatchQualityFn(JMF) {}
};
template<>
@@ -46,15 +50,24 @@ namespace llvm {
};
struct TargetMachineRegistry : public Registry<TargetMachine> {
+ /// getClosestStaticTargetForModule - Given an LLVM module, pick the best
+ /// target that is compatible with the module. If no close target can be
+ /// found, this returns null and sets the Error string to a reason.
+ static const entry *getClosestStaticTargetForModule(const Module &M,
+ std::string &Error);
+
+ /// getClosestTargetForJIT - Pick the best target that is compatible with
+ /// the current host. If no close target can be found, this returns null
+ /// and sets the Error string to a reason.
+ static const entry *getClosestTargetForJIT(std::string &Error);
};
//===--------------------------------------------------------------------===//
/// RegisterTarget - This class is used to make targets automatically register
- /// themselves with the tools they are linked with. Targets should define an
- /// single global Target instance and register it using the TargetRegistry
- /// interfaces. Targets must also include a static instance of this class.
- ///
+ /// themselves with the tool they are linked. Targets should define an
+ /// instance of this and implement the static methods described in the
+ /// TargetMachine comments.
/// The type 'TargetMachineImpl' should provide a constructor with two
/// parameters:
/// - const Module& M: the module that is being compiled:
@@ -63,19 +76,19 @@ namespace llvm {
template<class TargetMachineImpl>
struct RegisterTarget {
- RegisterTarget(Target &T, const char *Name, const char *ShortDesc)
- : Entry(T, Name, ShortDesc),
- Node(Entry) {
- TargetRegistry::RegisterTargetMachine(T, &Allocator);
- }
+ RegisterTarget(const char *Name, const char *ShortDesc)
+ : Entry(Name, ShortDesc, &Allocator,
+ &TargetMachineImpl::getModuleMatchQuality,
+ &TargetMachineImpl::getJITMatchQuality),
+ Node(Entry)
+ {}
private:
TargetMachineRegistry::entry Entry;
TargetMachineRegistry::node Node;
- static TargetMachine *Allocator(const Target &T, const Module &M,
- const std::string &FS) {
- return new TargetMachineImpl(T, M, FS);
+ static TargetMachine *Allocator(const Module &M, const std::string &FS) {
+ return new TargetMachineImpl(M, FS);
}
};
diff --git a/include/llvm/Target/TargetRegistry.h b/include/llvm/Target/TargetRegistry.h
index 95cf35c455..204d5b0c8f 100644
--- a/include/llvm/Target/TargetRegistry.h
+++ b/include/llvm/Target/TargetRegistry.h
@@ -42,8 +42,7 @@ namespace llvm {
typedef unsigned (*ModuleMatchQualityFnTy)(const Module &M);
typedef unsigned (*JITMatchQualityFnTy)();
- typedef TargetMachine *(*TargetMachineCtorTy)(const Target &,
- const Module &,
+ typedef TargetMachine *(*TargetMachineCtorTy)(const Module &,
const std::string &);
typedef FunctionPass *(*AsmPrinterCtorTy)(formatted_raw_ostream &,
TargetMachine &,
@@ -88,22 +87,18 @@ namespace llvm {
/// getShortDescription - Get a short description of the target.
const char *getShortDescription() const { return ShortDesc; }
- /// getJITMatchQuality - Get the quality of this targets match for use as a
- /// JIT.
- unsigned getJITMatchQuality() const { return JITMatchQualityFn(); }
-
/// createTargetMachine - Create a target specific machine implementation.
TargetMachine *createTargetMachine(const Module &M,
- const std::string &Features) const {
+ const std::string &Features) {
if (!TargetMachineCtorFn)
return 0;
- return TargetMachineCtorFn(*this, M, Features);
+ return TargetMachineCtorFn(M, Features);
}
/// createAsmPrinter - Create a target specific assembly printer pass.
FunctionPass *createAsmPrinter(formatted_raw_ostream &OS,
TargetMachine &M,
- bool Verbose) const {
+ bool Verbose) {
if (!AsmPrinterCtorFn)
return 0;
return AsmPrinterCtorFn(OS, M, Verbose);
@@ -140,8 +135,7 @@ namespace llvm {
/// @name Target Registration
/// @{
- /// RegisterTarget - Register the given target. Attempts to register a
- /// target which has already been registered will be ignored.
+ /// RegisterTarget - Register the given target.
///
/// Clients are responsible for ensuring that registration doesn't occur
/// while another thread is attempting to access the registry. Typically
diff --git a/include/llvm/Target/TargetSelect.h b/include/llvm/Target/TargetSelect.h
index a360f731ba..19b660b52d 100644
--- a/include/llvm/Target/TargetSelect.h
+++ b/include/llvm/Target/TargetSelect.h
@@ -58,9 +58,7 @@ namespace llvm {
inline bool InitializeNativeTarget() {
// If we have a native target, initialize it to ensure it is linked in.
#ifdef LLVM_NATIVE_ARCH
-#define DoInit2(TARG) \
- LLVMInitialize ## TARG ## Info (); \
- LLVMInitialize ## TARG ()
+#define DoInit2(TARG) LLVMInitialize ## TARG ()
#define DoInit(T) DoInit2(T)
DoInit(LLVM_NATIVE_ARCH);
return false;
diff --git a/lib/ExecutionEngine/JIT/TargetSelect.cpp b/lib/ExecutionEngine/JIT/TargetSelect.cpp
index a4157bcd7b..24dd013639 100644
--- a/lib/ExecutionEngine/JIT/TargetSelect.cpp
+++ b/lib/ExecutionEngine/JIT/TargetSelect.cpp
@@ -45,16 +45,16 @@ ExecutionEngine *JIT::createJIT(ModuleProvider *MP, std::string *ErrorStr,
JITMemoryManager *JMM,
CodeGenOpt::Level OptLevel,
bool AllocateGVsWithCode) {
- const Target *TheTarget;
- if (MArch == 0) {
+ const TargetMachineRegistry::entry *TheArch = MArch;
+ if (TheArch == 0) {
std::string Error;
- TheTarget = TargetRegistry::getClosestTargetForJIT(Error);
- if (TheTarget == 0) {
+ TheArch = TargetMachineRegistry::getClosestTargetForJIT(Error);
+ if (TheArch == 0) {
if (ErrorStr)
*ErrorStr = Error;
return 0;
}
- } else if (TheTarget->getJITMatchQuality() == 0) {
+ } else if (TheArch->JITMatchQualityFn() == 0) {
cerr << "WARNING: This target JIT is not designed for the host you are"
<< " running. If bad things happen, please choose a different "
<< "-march switch.\n";
@@ -71,8 +71,7 @@ ExecutionEngine *JIT::createJIT(ModuleProvider *MP, std::string *ErrorStr,
}
// Allocate a target...
- TargetMachine *Target =
- TheTarget->createTargetMachine(*MP->getModule(), FeaturesStr);
+ TargetMachine *Target = TheArch->CtorFn(*MP->getModule(), FeaturesStr);
assert(Target && "Could not allocate target machine!");
// If the target supports JIT code generation, return a new JIT now.
diff --git a/lib/Support/TargetRegistry.cpp b/lib/Support/TargetRegistry.cpp
index 77cf2dd72c..258d703d16 100644
--- a/lib/Support/TargetRegistry.cpp
+++ b/lib/Support/TargetRegistry.cpp
@@ -111,13 +111,15 @@ void TargetRegistry::RegisterTarget(Target &T,
Target::TripleMatchQualityFnTy TQualityFn,
Target::ModuleMatchQualityFnTy MQualityFn,
Target::JITMatchQualityFnTy JITQualityFn) {
+ // Note that we don't require the constructor functions already be defined, in
+ // case a module happens to initialize the optional functionality before the
+ // target.
+ assert(!T.Next && !T.Name && !T.ShortDesc && !T.TripleMatchQualityFn &&
+ !T.ModuleMatchQualityFn && !T.JITMatchQualityFn &&
+ "This Target already registered!");
+
assert(Name && ShortDesc && TQualityFn && MQualityFn && JITQualityFn &&
"Missing required target information!");
-
- // Check if this target has already been initialized, we allow this as a
- // convenience to some clients.
- if (T.Name)
- return;
// Add to the list of targets.
T.Next = FirstTarget;
diff --git a/lib/Target/ARM/ARM.h b/lib/Target/ARM/ARM.h
index 1b5b828395..f6ae6806fd 100644
--- a/lib/Target/ARM/ARM.h
+++ b/lib/Target/ARM/ARM.h
@@ -94,7 +94,7 @@ inline static const char *ARMCondCodeToString(ARMCC::CondCodes CC) {
FunctionPass *createARMISelDag(ARMBaseTargetMachine &TM);
FunctionPass *createARMCodePrinterPass(formatted_raw_ostream &O,
- TargetMachine &TM,
+ ARMBaseTargetMachine &TM,
bool Verbose);
FunctionPass *createARMCodeEmitterPass(ARMBaseTargetMachine &TM,
MachineCodeEmitter &MCE);
diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp
index ad80020738..932659d8b6 100644
--- a/lib/Target/ARM/ARMTargetMachine.cpp
+++ b/lib/Target/ARM/ARMTargetMachine.cpp
@@ -36,11 +36,8 @@ extern "C" int ARMTargetMachineModule;
int ARMTargetMachineModule = 0;
// Register the target.
-extern Target TheARMTarget;
-static RegisterTarget<ARMTargetMachine> X(TheARMTarget, "arm", "ARM");
-
-extern Target TheThumbTarget;
-static RegisterTarget<ThumbTargetMachine> Y(TheThumbTarget, "thumb", "Thumb");
+static RegisterTarget<ARMTargetMachine> X("arm", "ARM");
+static RegisterTarget<ThumbTargetMachine> Y("thumb", "Thumb");
// Force static initialization.
extern "C" void LLVMInitializeARMTarget() { }
@@ -48,32 +45,57 @@ extern "C" void LLVMInitializeARMTarget() { }
// No assembler printer by default
ARMBaseTargetMachine::AsmPrinterCtorFn ARMBaseTargetMachine::AsmPrinterCtor = 0;
+/// ThumbTargetMachine - Create an Thumb architecture model.
+///
+unsigned ThumbTargetMachine::getJITMatchQuality() {
+#if defined(__thumb__)
+ return 10;
+#endif
+ return 0;
+}
+
+unsigned ThumbTargetMachine::getModuleMatchQuality(const Module &M) {
+ std::string TT = M.getTargetTriple();
+ // Match thumb-foo-bar, as well as things like thumbv5blah-*
+ if (TT.size() >= 6 &&
+ (TT.substr(0, 6) == "thumb-" || TT.substr(0, 6) == "thumbv"))
+ return 20;
+
+ // If the target triple is something non-thumb, we don't match.
+ if (!TT.empty()) return 0;
+
+ if (M.getEndianness() == Module::LittleEndian &&
+ M.getPointerSize() == Module::Pointer32)
+ return 10; // Weak match
+ else if (M.getEndianness() != Module::AnyEndianness ||
+ M.getPointerSize() != Module::AnyPointerSize)
+ return 0; // Match for some other target
+
+ return getJITMatchQuality()/2;
+}
+
/// TargetMachine ctor - Create an ARM architecture model.
///
-ARMBaseTargetMachine::ARMBaseTargetMachine(const Target &T,
- const Module &M,
+ARMBaseTargetMachine::ARMBaseTargetMachine(const Module &M,
const std::string &FS,
bool isThumb)
- : LLVMTargetMachine(T),
- Subtarget(M, FS, isThumb),
+ : Subtarget(M, FS, isThumb),
FrameInfo(Subtarget),
JITInfo(),
InstrItins(Subtarget.getInstrItineraryData()) {
DefRelocModel = getRelocationModel();
}
-ARMTargetMachine::ARMTargetMachine(const Target &T, const Module &M,
- const std::string &FS)
- : ARMBaseTargetMachine(T, M, FS, false), InstrInfo(Subtarget),
+ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS)
+ : ARMBaseTargetMachine(M, FS, false), InstrInfo(Subtarget),
DataLayout(Subtarget.isAPCS_ABI() ?
std::string("e-p:32:32-f64:32:32-i64:32:32") :
std::string("e-p:32:32-f64:64:64-i64:64:64")),
TLInfo(*this) {
}
-ThumbTargetMachine::ThumbTargetMachine(const Target &T, const Module &M,
- const std::string &FS)
- : ARMBaseTargetMachine(T, M, FS, true),
+ThumbTargetMachine::ThumbTargetMachine(const Module &M, const std::string &FS)
+ : ARMBaseTargetMachine(M, FS, true),
DataLayout(Subtarget.isAPCS_ABI() ?
std::string("e-p:32:32-f64:32:32-i64:32:32-"
"i16:16:32-i8:8:32-i1:8:32-a:0:32") :
@@ -87,6 +109,32 @@ ThumbTargetMachine::ThumbTargetMachine(const Target &T, const Module &M,
InstrInfo = new Thumb1InstrInfo(Subtarget);
}
+unsigned ARMTargetMachine::getJITMatchQuality() {
+#if defined(__arm__)
+ return 10;
+#endif
+ return 0;
+}
+
+unsigned ARMTargetMachine::getModuleMatchQuality(const Module &M) {
+ std::string TT = M.getTargetTriple();
+ // Match arm-foo-bar, as well as things like armv5blah-*
+ if (TT.size() >= 4 &&
+ (TT.substr(0, 4) == "arm-" || TT.substr(0, 4) == "armv"))
+ return 20;
+ // If the target triple is something non-arm, we don't match.
+ if (!TT.empty()) return 0;
+
+ if (M.getEndianness() == Module::LittleEndian &&
+ M.getPointerSize() == Module::Pointer32)
+ return 10; // Weak match
+ else if (M.getEndianness() != Module::AnyEndianness ||
+ M.getPointerSize() != Module::AnyPointerSize)
+ return 0; // Match for some other target
+
+ return getJITMatchQuality()/2;
+}
+
const TargetAsmInfo *ARMBaseTargetMachine::createTargetAsmInfo() const {
switch (Subtarget.TargetType) {
diff --git a/lib/Target/ARM/ARMTargetMachine.h b/lib/Target/ARM/ARMTargetMachine.h
index 3fe259ad08..56b18ae36a 100644
--- a/lib/Target/ARM/ARMTargetMachine.h
+++ b/lib/Target/ARM/ARMTargetMachine.h
@@ -42,13 +42,12 @@ protected:
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
// set this functions to ctor pointer at startup time if they are linked in.
typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
- TargetMachine &tm,
+ ARMBaseTargetMachine &tm,
bool verbose);
static AsmPrinterCtorFn AsmPrinterCtor;
public:
- ARMBaseTargetMachine(const Target &T, const Module &M, const std::string &FS,
- bool isThumb);
+ ARMBaseTargetMachine(const Module &M, const std::string &FS, bool isThumb);
virtual const ARMFrameInfo *getFrameInfo() const { return &FrameInfo; }
virtual ARMJITInfo *getJITInfo() { return &JITInfo; }
@@ -61,6 +60,9 @@ public:
AsmPrinterCtor = F;
}
+ static unsigned getModuleMatchQuality(const Module &M);
+ static unsigned getJITMatchQuality();
+
virtual const TargetAsmInfo *createTargetAsmInfo() const;
// Pass Pipeline Configuration
@@ -97,7 +99,7 @@ class ARMTargetMachine : public ARMBaseTargetMachine {
const TargetData DataLayout; // Calculates type size & alignment
ARMTargetLowering TLInfo;
public:
- ARMTargetMachine(const Target &T, const Module &M, const std::string &FS);
+ ARMTargetMachine(const Module &M, const std::string &FS);
virtual const ARMRegisterInfo *getRegisterInfo() const {
return &InstrInfo.getRegisterInfo();
@@ -123,7 +125,7 @@ class ThumbTargetMachine : public ARMBaseTargetMachine {
const TargetData DataLayout; // Calculates type size & alignment
ARMTargetLowering TLInfo;
public:
- ThumbTargetMachine(const Target &T, const Module &M, const std::string &FS);
+ ThumbTargetMachine(const Module &M, const std::string &FS);
/// returns either Thumb1RegisterInfo of Thumb2RegisterInfo
virtual const ARMBaseRegisterInfo *getRegisterInfo() const {
diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
index 098f5d3225..de6adbde55 100644
--- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
+++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
@@ -31,7 +31,6 @@
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
-#include "llvm/Target/TargetRegistry.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSet.h"
@@ -1288,7 +1287,7 @@ bool ARMAsmPrinter::doFinalization(Module &M) {
/// regardless of whether the function is in SSA form.
///
FunctionPass *llvm::createARMCodePrinterPass(formatted_raw_ostream &o,
- TargetMachine &tm,
+ ARMBaseTargetMachine &tm,
bool verbose) {
return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
}
@@ -1302,8 +1301,4 @@ namespace {
}
// Force static initialization.
-extern "C" void LLVMInitializeARMAsmPrinter() {
- extern Target TheARMTarget, TheThumbTarget;
- TargetRegistry::RegisterAsmPrinter(TheARMTarget, createARMCodePrinterPass);
- TargetRegistry::RegisterAsmPrinter(TheThumbTarget, createARMCodePrinterPass);
-}
+extern "C" void LLVMInitializeARMAsmPrinter() { }
diff --git a/lib/Target/Alpha/AlphaTargetMachine.cpp b/lib/Target/Alpha/AlphaTargetMachine.cpp
index a7a8162c12..625d0cea54 100644
--- a/lib/Target/Alpha/AlphaTargetMachine.cpp
+++ b/lib/Target/Alpha/AlphaTargetMachine.cpp
@@ -22,9 +22,7 @@
using namespace llvm;
// Register the targets
-extern Target TheAlphaTarget;
-static RegisterTarget<AlphaTargetMachine> X(TheAlphaTarget, "alpha",
- "Alpha [experimental]");
+static RegisterTarget<AlphaTargetMachine> X("alpha", "Alpha [experimental]");
// No assembler printer by default
AlphaTargetMachine::AsmPrinterCtorFn AlphaTargetMachine::AsmPrinterCtor = 0;
@@ -36,10 +34,35 @@ const TargetAsmInfo *AlphaTargetMachine::createTargetAsmInfo() const {
return new AlphaTargetAsmInfo(*this);
}
-AlphaTargetMachine::AlphaTargetMachine(const Target &T, const Module &M,
- const std::string &FS)
- : LLVMTargetMachine(T),
- DataLayout("e-f128:128:128"),
+unsigned AlphaTargetMachine::getModuleMatchQuality(const Module &M) {
+ // We strongly match "alpha*".
+ std::string TT = M.getTargetTriple();
+ if (TT.size() >= 5 && TT[0] == 'a' && TT[1] == 'l' && TT[2] == 'p' &&
+ TT[3] == 'h' && TT[4] == 'a')
+ return 20;
+ // If the target triple is something non-alpha, we don't match.
+ if (!TT.empty()) return 0;
+
+ if (M.getEndianness() == Module::LittleEndian &&
+ M.getPointerSize() == Module::Pointer64)
+ return 10; // Weak match
+ else if (M.getEndianness() != Module::AnyEndianness ||
+