Daniel Dunbar | 0eb6699 | 2009-07-15 06:35:19 +0000 | [diff] [blame] | 1 | //===-- MipsTargetInfo.cpp - Mips Target Implementation -------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Daniel Dunbar | 0b0441e | 2009-07-18 23:03:22 +0000 | [diff] [blame^] | 10 | #include "Mips.h" |
Daniel Dunbar | 0eb6699 | 2009-07-15 06:35:19 +0000 | [diff] [blame] | 11 | #include "llvm/Module.h" |
| 12 | #include "llvm/Target/TargetRegistry.h" |
| 13 | using namespace llvm; |
| 14 | |
Daniel Dunbar | 0b0441e | 2009-07-18 23:03:22 +0000 | [diff] [blame^] | 15 | Target llvm::TheMipsTarget; |
Daniel Dunbar | 0eb6699 | 2009-07-15 06:35:19 +0000 | [diff] [blame] | 16 | |
| 17 | static unsigned Mips_JITMatchQuality() { |
| 18 | return 0; |
| 19 | } |
| 20 | |
| 21 | static unsigned Mips_TripleMatchQuality(const std::string &TT) { |
| 22 | // We strongly match "mips*-*". |
| 23 | if (TT.size() >= 5 && std::string(TT.begin(), TT.begin()+5) == "mips-") |
| 24 | return 20; |
| 25 | |
| 26 | if (TT.size() >= 13 && std::string(TT.begin(), |
| 27 | TT.begin()+13) == "mipsallegrex-") |
| 28 | return 20; |
| 29 | |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | static unsigned Mips_ModuleMatchQuality(const Module &M) { |
| 34 | // Check for a triple match. |
| 35 | if (unsigned Q = Mips_TripleMatchQuality(M.getTargetTriple())) |
| 36 | return Q; |
| 37 | |
| 38 | // Otherwise if the target triple is non-empty, we don't match. |
| 39 | if (!M.getTargetTriple().empty()) return 0; |
| 40 | |
| 41 | return 0; |
| 42 | } |
| 43 | |
Daniel Dunbar | 0b0441e | 2009-07-18 23:03:22 +0000 | [diff] [blame^] | 44 | Target llvm::TheMipselTarget; |
Daniel Dunbar | 0eb6699 | 2009-07-15 06:35:19 +0000 | [diff] [blame] | 45 | |
| 46 | static unsigned Mipsel_JITMatchQuality() { |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | static unsigned Mipsel_TripleMatchQuality(const std::string &TT) { |
| 51 | // We strongly match "mips*el-*". |
| 52 | if (TT.size() >= 7 && std::string(TT.begin(), TT.begin()+7) == "mipsel-") |
| 53 | return 20; |
| 54 | |
| 55 | if (TT.size() >= 15 && std::string(TT.begin(), |
| 56 | TT.begin()+15) == "mipsallegrexel-") |
| 57 | return 20; |
| 58 | |
| 59 | if (TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "psp") |
| 60 | return 20; |
| 61 | |
| 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | static unsigned Mipsel_ModuleMatchQuality(const Module &M) { |
| 66 | // Check for a triple match. |
| 67 | if (unsigned Q = Mipsel_TripleMatchQuality(M.getTargetTriple())) |
| 68 | return Q; |
| 69 | |
| 70 | // Otherwise if the target triple is non-empty, we don't match. |
| 71 | if (!M.getTargetTriple().empty()) return 0; |
| 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | extern "C" void LLVMInitializeMipsTargetInfo() { |
| 77 | TargetRegistry::RegisterTarget(TheMipsTarget, "mips", |
| 78 | "Mips", |
| 79 | &Mips_TripleMatchQuality, |
| 80 | &Mips_ModuleMatchQuality, |
| 81 | &Mips_JITMatchQuality); |
| 82 | |
| 83 | TargetRegistry::RegisterTarget(TheMipselTarget, "mipsel", |
| 84 | "Mipsel", |
| 85 | &Mipsel_TripleMatchQuality, |
| 86 | &Mipsel_ModuleMatchQuality, |
| 87 | &Mipsel_JITMatchQuality); |
| 88 | } |