Kill Target specific ModuleMatchQuality stuff.

- This was overkill and inconsistently implemented.

llvm-svn: 77114
This commit is contained in:
Daniel Dunbar 2009-07-26 02:22:58 +00:00
parent 4f7dfaf650
commit bc981d8efa
16 changed files with 13 additions and 286 deletions

View File

@ -43,8 +43,6 @@ namespace llvm {
class Target {
private:
typedef unsigned (*TripleMatchQualityFnTy)(const std::string &TT);
typedef unsigned (*ModuleMatchQualityFnTy)(const Module &M);
typedef unsigned (*JITMatchQualityFnTy)();
typedef TargetMachine *(*TargetMachineCtorTy)(const Target &,
const Module &,
@ -64,10 +62,6 @@ namespace llvm {
/// of a triple.
TripleMatchQualityFnTy TripleMatchQualityFn;
/// ModuleMatchQualityFn - The target function for rating the match quality
/// of a module.
ModuleMatchQualityFnTy ModuleMatchQualityFn;
/// Name - The target name.
const char *Name;
@ -222,15 +216,12 @@ namespace llvm {
/// string.
/// @param TQualityFn - The triple match quality computation function for
/// this target.
/// @param MQualityFn - The module match quality computation function for
/// this target.
/// @param HasJIT - Whether the target supports JIT code
/// generation.
static void RegisterTarget(Target &T,
const char *Name,
const char *ShortDesc,
Target::TripleMatchQualityFnTy TQualityFn,
Target::ModuleMatchQualityFnTy MQualityFn,
bool HasJIT = false);
/// RegisterTargetMachine - Register a TargetMachine implementation for the
@ -294,9 +285,7 @@ namespace llvm {
/// struct FooInfo {
/// static const bool HasJIT = ...;
///
/// static unsigned getJITMatchQuality() { ... }
/// static unsigned getTripleMatchQuality(const std::string &) { ... }
/// static unsigned getModuleMatchQuality(const Module &) { ... }
/// };
/// }
///
@ -308,7 +297,6 @@ namespace llvm {
RegisterTarget(Target &T, const char *Name, const char *Desc) {
TargetRegistry::RegisterTarget(T, Name, Desc,
&TargetInfoImpl::getTripleMatchQuality,
&TargetInfoImpl::getModuleMatchQuality,
TargetInfoImpl::HasJIT);
}
};

View File

@ -74,9 +74,8 @@ void TargetRegistry::RegisterTarget(Target &T,
const char *Name,
const char *ShortDesc,
Target::TripleMatchQualityFnTy TQualityFn,
Target::ModuleMatchQualityFnTy MQualityFn,
bool HasJIT) {
assert(Name && ShortDesc && TQualityFn && MQualityFn &&
assert(Name && ShortDesc && TQualityFn &&
"Missing required target information!");
// Check if this target has already been initialized, we allow this as a
@ -91,7 +90,6 @@ void TargetRegistry::RegisterTarget(Target &T,
T.Name = Name;
T.ShortDesc = ShortDesc;
T.TripleMatchQualityFn = TQualityFn;
T.ModuleMatchQualityFn = MQualityFn;
T.HasJIT = HasJIT;
}

View File

@ -23,24 +23,6 @@ static unsigned ARM_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned ARM_ModuleMatchQuality(const Module &M) {
// Check for a triple match.
if (unsigned Q = ARM_TripleMatchQuality(M.getTargetTriple()))
return Q;
// Otherwise if the target triple is non-empty, we don't match.
if (!M.getTargetTriple().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 0;
}
Target llvm::TheThumbTarget;
static unsigned Thumb_TripleMatchQuality(const std::string &TT) {
@ -52,34 +34,14 @@ static unsigned Thumb_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned Thumb_ModuleMatchQuality(const Module &M) {
// Check for a triple match.
if (unsigned Q = Thumb_TripleMatchQuality(M.getTargetTriple()))
return Q;
// Otherwise if the target triple is non-empty, we don't match.
if (!M.getTargetTriple().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 0;
}
extern "C" void LLVMInitializeARMTargetInfo() {
TargetRegistry::RegisterTarget(TheARMTarget, "arm",
"ARM",
&ARM_TripleMatchQuality,
&ARM_ModuleMatchQuality,
/*HasJIT=*/true);
TargetRegistry::RegisterTarget(TheThumbTarget, "thumb",
"Thumb",
&Thumb_TripleMatchQuality,
&Thumb_ModuleMatchQuality,
/*HasJIT=*/true);
}

View File

@ -23,28 +23,9 @@ static unsigned Alpha_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned Alpha_ModuleMatchQuality(const Module &M) {
// Check for a triple match.
if (unsigned Q = Alpha_TripleMatchQuality(M.getTargetTriple()))
return Q;
// Otherwise if the target triple is non-empty, we don't match.
if (!M.getTargetTriple().empty()) return 0;
if (M.getEndianness() == Module::LittleEndian &&
M.getPointerSize() == Module::Pointer64)
return 10; // Weak match
else if (M.getEndianness() != Module::AnyEndianness ||
M.getPointerSize() != Module::AnyPointerSize)
return 0; // Match for some other target
return 0;
}
extern "C" void LLVMInitializeAlphaTargetInfo() {
TargetRegistry::RegisterTarget(TheAlphaTarget, "alpha",
"Alpha [experimental]",
&Alpha_TripleMatchQuality,
&Alpha_ModuleMatchQuality,
/*HasJIT=*/true);
}

View File

@ -20,15 +20,8 @@ static unsigned CBackend_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned CBackend_ModuleMatchQuality(const Module &M) {
// This class always works, but must be requested explicitly on
// llc command line.
return 0;
}
extern "C" void LLVMInitializeCBackendTargetInfo() {
TargetRegistry::RegisterTarget(TheCBackendTarget, "c",
"C backend",
&CBackend_TripleMatchQuality,
&CBackend_ModuleMatchQuality);
&CBackend_TripleMatchQuality);
}

View File

@ -25,20 +25,8 @@ static unsigned CellSPU_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned CellSPU_ModuleMatchQuality(const Module &M) {
// Check for a triple match.
if (unsigned Q = CellSPU_TripleMatchQuality(M.getTargetTriple()))
return Q;
// Otherwise if the target triple is non-empty, we don't match.
if (!M.getTargetTriple().empty()) return 0;
return 0;
}
extern "C" void LLVMInitializeCellSPUTargetInfo() {
TargetRegistry::RegisterTarget(TheCellSPUTarget, "cellspu",
"STI CBEA Cell SPU [experimental]",
&CellSPU_TripleMatchQuality,
&CellSPU_ModuleMatchQuality);
&CellSPU_TripleMatchQuality);
}

View File

@ -19,14 +19,8 @@ static unsigned CppBackend_TripleMatchQuality(const std::string &TT) {
return 1;
}
static unsigned CppBackend_ModuleMatchQuality(const Module &M) {
// This class always works, but shouldn't be the default in most cases.
return 1;
}
extern "C" void LLVMInitializeCppBackendTargetInfo() {
TargetRegistry::RegisterTarget(TheCppBackendTarget, "cpp",
"C++ backend",
&CppBackend_TripleMatchQuality,
&CppBackend_ModuleMatchQuality);
&CppBackend_TripleMatchQuality);
}

View File

@ -19,14 +19,8 @@ static unsigned MSIL_TripleMatchQuality(const std::string &TT) {
return 1;
}
static unsigned MSIL_ModuleMatchQuality(const Module &M) {
// This class always works, but shouldn't be the default in most cases.
return 1;
}
extern "C" void LLVMInitializeMSILTargetInfo() {
TargetRegistry::RegisterTarget(TheMSILTarget, "msil",
"MSIL backend",
&MSIL_TripleMatchQuality,
&MSIL_ModuleMatchQuality);
&MSIL_TripleMatchQuality);
}

View File

@ -23,20 +23,8 @@ static unsigned MSP430_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned MSP430_ModuleMatchQuality(const Module &M) {
// Check for a triple match.
if (unsigned Q = MSP430_TripleMatchQuality(M.getTargetTriple()))
return Q;
// Otherwise if the target triple is non-empty, we don't match.
if (!M.getTargetTriple().empty()) return 0;
return 0;
}
extern "C" void LLVMInitializeMSP430TargetInfo() {
TargetRegistry::RegisterTarget(TheMSP430Target, "msp430",
"MSP430 [experimental]",
&MSP430_TripleMatchQuality,
&MSP430_ModuleMatchQuality);
&MSP430_TripleMatchQuality);
}

View File

@ -26,17 +26,6 @@ static unsigned Mips_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned Mips_ModuleMatchQuality(const Module &M) {
// Check for a triple match.
if (unsigned Q = Mips_TripleMatchQuality(M.getTargetTriple()))
return Q;
// Otherwise if the target triple is non-empty, we don't match.
if (!M.getTargetTriple().empty()) return 0;
return 0;
}
Target llvm::TheMipselTarget;
static unsigned Mipsel_TripleMatchQuality(const std::string &TT) {
@ -54,25 +43,12 @@ static unsigned Mipsel_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned Mipsel_ModuleMatchQuality(const Module &M) {
// Check for a triple match.
if (unsigned Q = Mipsel_TripleMatchQuality(M.getTargetTriple()))
return Q;
// Otherwise if the target triple is non-empty, we don't match.
if (!M.getTargetTriple().empty()) return 0;
return 0;
}
extern "C" void LLVMInitializeMipsTargetInfo() {
TargetRegistry::RegisterTarget(TheMipsTarget, "mips",
"Mips",
&Mips_TripleMatchQuality,
&Mips_ModuleMatchQuality);
&Mips_TripleMatchQuality);
TargetRegistry::RegisterTarget(TheMipselTarget, "mipsel",
"Mipsel",
&Mipsel_TripleMatchQuality,
&Mipsel_ModuleMatchQuality);
&Mipsel_TripleMatchQuality);
}

View File

@ -18,28 +18,18 @@ static unsigned PIC16_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned PIC16_ModuleMatchQuality(const Module &M) {
return 0;
}
Target llvm::TheCooperTarget;
static unsigned Cooper_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned Cooper_ModuleMatchQuality(const Module &M) {
return 0;
}
extern "C" void LLVMInitializePIC16TargetInfo() {
TargetRegistry::RegisterTarget(ThePIC16Target, "pic16",
"PIC16 14-bit [experimental]",
&PIC16_TripleMatchQuality,
&PIC16_ModuleMatchQuality);
&PIC16_TripleMatchQuality);
TargetRegistry::RegisterTarget(TheCooperTarget, "cooper",
"PIC16 Cooper [experimental]",
&Cooper_TripleMatchQuality,
&Cooper_ModuleMatchQuality);
&Cooper_TripleMatchQuality);
}

View File

@ -22,24 +22,6 @@ static unsigned PPC32_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned PPC32_ModuleMatchQuality(const Module &M) {
// Check for a triple match.
if (unsigned Q = PPC32_TripleMatchQuality(M.getTargetTriple()))
return Q;
// Otherwise if the target triple is non-empty, we don't match.
if (!M.getTargetTriple().empty()) return 0;
if (M.getEndianness() == Module::BigEndian &&
M.getPointerSize() == Module::Pointer64)
return 10; // Weak match
else if (M.getEndianness() != Module::AnyEndianness ||
M.getPointerSize() != Module::AnyPointerSize)
return 0; // Match for some other target
return 0;
}
Target llvm::ThePPC64Target;
static unsigned PPC64_TripleMatchQuality(const std::string &TT) {
@ -50,34 +32,14 @@ static unsigned PPC64_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned PPC64_ModuleMatchQuality(const Module &M) {
// Check for a triple match.
if (unsigned Q = PPC64_TripleMatchQuality(M.getTargetTriple()))
return Q;
// Otherwise if the target triple is non-empty, we don't match.
if (!M.getTargetTriple().empty()) return 0;
if (M.getEndianness() == Module::BigEndian &&
M.getPointerSize() == Module::Pointer64)
return 10; // Weak match
else if (M.getEndianness() != Module::AnyEndianness ||
M.getPointerSize() != Module::AnyPointerSize)
return 0; // Match for some other target
return 0;
}
extern "C" void LLVMInitializePowerPCTargetInfo() {
TargetRegistry::RegisterTarget(ThePPC32Target, "ppc32",
"PowerPC 32",
&PPC32_TripleMatchQuality,
&PPC32_ModuleMatchQuality,
/*HasJIT=*/true);
TargetRegistry::RegisterTarget(ThePPC64Target, "ppc64",
"PowerPC 64",
&PPC64_TripleMatchQuality,
&PPC64_ModuleMatchQuality,
/*HasJIT=*/true);
}

View File

@ -21,37 +21,8 @@ static unsigned Sparc_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned Sparc_ModuleMatchQuality(const Module &M) {
// Check for a triple match.
if (unsigned Q = Sparc_TripleMatchQuality(M.getTargetTriple()))
return Q;
// Otherwise if the target triple is non-empty, we don't match.
if (!M.getTargetTriple().empty()) return 0;
// FIXME: This is bad, the target matching algorithm shouldn't depend on the
// host.
if (M.getEndianness() == Module::BigEndian &&
M.getPointerSize() == Module::Pointer32)
#ifdef __sparc__
return 20; // BE/32 ==> Prefer sparc on sparc
#else
return 5; // BE/32 ==> Prefer ppc elsewhere
#endif
else if (M.getEndianness() != Module::AnyEndianness ||
M.getPointerSize() != Module::AnyPointerSize)
return 0; // Match for some other target
#if defined(__sparc__)
return 10;
#else
return 0;
#endif
}
extern "C" void LLVMInitializeSparcTargetInfo() {
TargetRegistry::RegisterTarget(TheSparcTarget, "sparc",
"Sparc",
&Sparc_TripleMatchQuality,
&Sparc_ModuleMatchQuality);
&Sparc_TripleMatchQuality);
}

View File

@ -23,18 +23,8 @@ static unsigned SystemZ_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned SystemZ_ModuleMatchQuality(const Module &M) {
// Check for a triple match.
if (unsigned Q = SystemZ_TripleMatchQuality(M.getTargetTriple()))
return Q;
// Otherwise we don't match.
return 0;
}
extern "C" void LLVMInitializeSystemZTargetInfo() {
TargetRegistry::RegisterTarget(TheSystemZTarget, "systemz",
"SystemZ",
&SystemZ_TripleMatchQuality,
&SystemZ_ModuleMatchQuality);
&SystemZ_TripleMatchQuality);
}

View File

@ -23,24 +23,6 @@ static unsigned X86_32_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned X86_32_ModuleMatchQuality(const Module &M) {
// Check for a triple match.
if (unsigned Q = X86_32_TripleMatchQuality(M.getTargetTriple()))
return Q;
// If the target triple is something non-X86, we don't match.
if (!M.getTargetTriple().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 0;
}
Target llvm::TheX86_64Target;
static unsigned X86_64_TripleMatchQuality(const std::string &TT) {
@ -52,34 +34,14 @@ static unsigned X86_64_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned X86_64_ModuleMatchQuality(const Module &M) {
// Check for a triple match.
if (unsigned Q = X86_64_TripleMatchQuality(M.getTargetTriple()))
return Q;
// If the target triple is something non-X86-64, we don't match.
if (!M.getTargetTriple().empty()) return 0;
if (M.getEndianness() == Module::LittleEndian &&
M.getPointerSize() == Module::Pointer64)
return 10; // Weak match
else if (M.getEndianness() != Module::AnyEndianness ||
M.getPointerSize() != Module::AnyPointerSize)
return 0; // Match for some other target
return 0;
}
extern "C" void LLVMInitializeX86TargetInfo() {
TargetRegistry::RegisterTarget(TheX86_32Target, "x86",
"32-bit X86: Pentium-Pro and above",
&X86_32_TripleMatchQuality,
&X86_32_ModuleMatchQuality,
/*HasJIT=*/true);
TargetRegistry::RegisterTarget(TheX86_64Target, "x86-64",
"64-bit X86: EM64T and AMD64",
&X86_64_TripleMatchQuality,
&X86_64_ModuleMatchQuality,
/*HasJIT=*/true);
}

View File

@ -21,18 +21,8 @@ static unsigned XCore_TripleMatchQuality(const std::string &TT) {
return 0;
}
static unsigned XCore_ModuleMatchQuality(const Module &M) {
// Check for a triple match.
if (unsigned Q = XCore_TripleMatchQuality(M.getTargetTriple()))
return Q;
// Otherwise we don't match.
return 0;
}
extern "C" void LLVMInitializeXCoreTargetInfo() {
TargetRegistry::RegisterTarget(TheXCoreTarget, "xcore",
"XCore",
&XCore_TripleMatchQuality,
&XCore_ModuleMatchQuality);
&XCore_TripleMatchQuality);
}