blob: 1188a74f160c844df47992f14e935dc122f4ebcd [file] [log] [blame]
Daniel Dunbar0eb66992009-07-15 06:35:19 +00001//===-- 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 Dunbar0b0441e2009-07-18 23:03:22 +000010#include "Mips.h"
Daniel Dunbar0eb66992009-07-15 06:35:19 +000011#include "llvm/Module.h"
12#include "llvm/Target/TargetRegistry.h"
13using namespace llvm;
14
Daniel Dunbar0b0441e2009-07-18 23:03:22 +000015Target llvm::TheMipsTarget;
Daniel Dunbar0eb66992009-07-15 06:35:19 +000016
17static unsigned Mips_JITMatchQuality() {
18 return 0;
19}
20
21static 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
33static 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 Dunbar0b0441e2009-07-18 23:03:22 +000044Target llvm::TheMipselTarget;
Daniel Dunbar0eb66992009-07-15 06:35:19 +000045
46static unsigned Mipsel_JITMatchQuality() {
47 return 0;
48}
49
50static 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
65static 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
76extern "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}