The various "getModuleMatchQuality" implementations should return

zero if they see a target triple they don't understand.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38463 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2007-07-09 17:25:29 +00:00
parent 0f9d599dc9
commit 87bdba6d6a
7 changed files with 24 additions and 3 deletions

View File

@ -48,6 +48,9 @@ unsigned ThumbTargetMachine::getModuleMatchQuality(const Module &M) {
if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "thumb-")
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
@ -94,6 +97,8 @@ unsigned ARMTargetMachine::getModuleMatchQuality(const Module &M) {
std::string TT = M.getTargetTriple();
if (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "arm-")
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)

View File

@ -35,6 +35,8 @@ unsigned AlphaTargetMachine::getModuleMatchQuality(const Module &M) {
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)

View File

@ -50,6 +50,8 @@ unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) {
if (seenIA64)
return 20; // strong match
}
// If the target triple is something non-ia64, we don't match.
if (!TT.empty()) return 0;
#if defined(__ia64__) || defined(__IA64__)
return 5;

View File

@ -40,13 +40,14 @@ MipsTargetMachine(const Module &M, const std::string &FS):
// return 0 and must specify -march to gen MIPS code.
unsigned MipsTargetMachine::
getModuleMatchQuality(const Module &M)
{
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 the target triple is something non-mips, we don't match.
if (!TT.empty()) return 0;
return 0;
}

View File

@ -55,6 +55,9 @@ unsigned PPC32TargetMachine::getModuleMatchQuality(const Module &M) {
if (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "powerpc-")
return 20;
// If the target triple is something non-powerpc, we don't match.
if (!TT.empty()) return 0;
if (M.getEndianness() == Module::BigEndian &&
M.getPointerSize() == Module::Pointer32)
return 10; // Weak match

View File

@ -39,6 +39,9 @@ unsigned SparcTargetMachine::getModuleMatchQuality(const Module &M) {
std::string TT = M.getTargetTriple();
if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "sparc-")
return 20;
// If the target triple is something non-sparc, we don't match.
if (!TT.empty()) return 0;
if (M.getEndianness() == Module::BigEndian &&
M.getPointerSize() == Module::Pointer32)

View File

@ -62,6 +62,8 @@ unsigned X86_32TargetMachine::getModuleMatchQuality(const Module &M) {
if (TT.size() >= 5 && TT[0] == 'i' && TT[2] == '8' && TT[3] == '6' &&
TT[4] == '-' && TT[1] - '3' < 6)
return 20;
// If the target triple is something non-X86, we don't match.
if (!TT.empty()) return 0;
if (M.getEndianness() == Module::LittleEndian &&
M.getPointerSize() == Module::Pointer32)
@ -85,6 +87,9 @@ unsigned X86_64TargetMachine::getModuleMatchQuality(const Module &M) {
TT[3] == '6' && TT[4] == '4' && TT[5] == '-')
return 20;
// If the target triple is something non-X86-64, we don't match.
if (!TT.empty()) return 0;
if (M.getEndianness() == Module::LittleEndian &&
M.getPointerSize() == Module::Pointer64)
return 10; // Weak match