Daniel Dunbar | c984df8 | 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 | 4cb1e13 | 2009-07-18 23:03:22 +0000 | [diff] [blame] | 10 | #include "Mips.h" |
Daniel Dunbar | c984df8 | 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 | 4cb1e13 | 2009-07-18 23:03:22 +0000 | [diff] [blame] | 15 | Target llvm::TheMipsTarget; |
Daniel Dunbar | c984df8 | 2009-07-15 06:35:19 +0000 | [diff] [blame] | 16 | |
Daniel Dunbar | c984df8 | 2009-07-15 06:35:19 +0000 | [diff] [blame] | 17 | static unsigned Mips_TripleMatchQuality(const std::string &TT) { |
| 18 | // We strongly match "mips*-*". |
| 19 | if (TT.size() >= 5 && std::string(TT.begin(), TT.begin()+5) == "mips-") |
| 20 | return 20; |
| 21 | |
| 22 | if (TT.size() >= 13 && std::string(TT.begin(), |
| 23 | TT.begin()+13) == "mipsallegrex-") |
| 24 | return 20; |
| 25 | |
| 26 | return 0; |
| 27 | } |
| 28 | |
Daniel Dunbar | 4cb1e13 | 2009-07-18 23:03:22 +0000 | [diff] [blame] | 29 | Target llvm::TheMipselTarget; |
Daniel Dunbar | c984df8 | 2009-07-15 06:35:19 +0000 | [diff] [blame] | 30 | |
Daniel Dunbar | c984df8 | 2009-07-15 06:35:19 +0000 | [diff] [blame] | 31 | static unsigned Mipsel_TripleMatchQuality(const std::string &TT) { |
| 32 | // We strongly match "mips*el-*". |
| 33 | if (TT.size() >= 7 && std::string(TT.begin(), TT.begin()+7) == "mipsel-") |
| 34 | return 20; |
| 35 | |
| 36 | if (TT.size() >= 15 && std::string(TT.begin(), |
| 37 | TT.begin()+15) == "mipsallegrexel-") |
| 38 | return 20; |
| 39 | |
| 40 | if (TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "psp") |
| 41 | return 20; |
| 42 | |
| 43 | return 0; |
| 44 | } |
| 45 | |
Daniel Dunbar | c984df8 | 2009-07-15 06:35:19 +0000 | [diff] [blame] | 46 | extern "C" void LLVMInitializeMipsTargetInfo() { |
| 47 | TargetRegistry::RegisterTarget(TheMipsTarget, "mips", |
| 48 | "Mips", |
Daniel Dunbar | fa27ff2 | 2009-07-26 02:22:58 +0000 | [diff] [blame] | 49 | &Mips_TripleMatchQuality); |
Daniel Dunbar | c984df8 | 2009-07-15 06:35:19 +0000 | [diff] [blame] | 50 | |
| 51 | TargetRegistry::RegisterTarget(TheMipselTarget, "mipsel", |
| 52 | "Mipsel", |
Daniel Dunbar | fa27ff2 | 2009-07-26 02:22:58 +0000 | [diff] [blame] | 53 | &Mipsel_TripleMatchQuality); |
Daniel Dunbar | c984df8 | 2009-07-15 06:35:19 +0000 | [diff] [blame] | 54 | } |