1 //===-- MipsTargetInfo.cpp - Mips Target Implementation -------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Module.h"
11 #include "llvm/Target/TargetRegistry.h"
16 static unsigned Mips_JITMatchQuality() {
20 static unsigned Mips_TripleMatchQuality(const std::string &TT) {
21 // We strongly match "mips*-*".
22 if (TT.size() >= 5 && std::string(TT.begin(), TT.begin()+5) == "mips-")
25 if (TT.size() >= 13 && std::string(TT.begin(),
26 TT.begin()+13) == "mipsallegrex-")
32 static unsigned Mips_ModuleMatchQuality(const Module &M) {
33 // Check for a triple match.
34 if (unsigned Q = Mips_TripleMatchQuality(M.getTargetTriple()))
37 // Otherwise if the target triple is non-empty, we don't match.
38 if (!M.getTargetTriple().empty()) return 0;
43 Target TheMipselTarget;
45 static unsigned Mipsel_JITMatchQuality() {
49 static unsigned Mipsel_TripleMatchQuality(const std::string &TT) {
50 // We strongly match "mips*el-*".
51 if (TT.size() >= 7 && std::string(TT.begin(), TT.begin()+7) == "mipsel-")
54 if (TT.size() >= 15 && std::string(TT.begin(),
55 TT.begin()+15) == "mipsallegrexel-")
58 if (TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "psp")
64 static unsigned Mipsel_ModuleMatchQuality(const Module &M) {
65 // Check for a triple match.
66 if (unsigned Q = Mipsel_TripleMatchQuality(M.getTargetTriple()))
69 // Otherwise if the target triple is non-empty, we don't match.
70 if (!M.getTargetTriple().empty()) return 0;
75 extern "C" void LLVMInitializeMipsTargetInfo() {
76 TargetRegistry::RegisterTarget(TheMipsTarget, "mips",
78 &Mips_TripleMatchQuality,
79 &Mips_ModuleMatchQuality,
80 &Mips_JITMatchQuality);
82 TargetRegistry::RegisterTarget(TheMipselTarget, "mipsel",
84 &Mipsel_TripleMatchQuality,
85 &Mipsel_ModuleMatchQuality,
86 &Mipsel_JITMatchQuality);