1 //===-- XCoreTargetInfo.cpp - XCore 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 
10 #include "llvm/Module.h"
11 #include "llvm/Target/TargetRegistry.h"
12 using namespace llvm;
13 
14 Target TheXCoreTarget;
15 
16 static unsigned XCore_JITMatchQuality() {
17   return 0;
18 }
19 
20 static unsigned XCore_TripleMatchQuality(const std::string &TT) {
21   if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "xcore-")
22     return 20;
23 
24   return 0;
25 }
26 
27 static unsigned XCore_ModuleMatchQuality(const Module &M) {
28   // Check for a triple match.
29   if (unsigned Q = XCore_TripleMatchQuality(M.getTargetTriple()))
30     return Q;
31 
32   // Otherwise we don't match.
33   return 0;
34 }
35 
36 extern "C" void LLVMInitializeXCoreTargetInfo() {
37   TargetRegistry::RegisterTarget(TheXCoreTarget, "xcore",
38                                   "XCore",
39                                   &XCore_TripleMatchQuality,
40                                   &XCore_ModuleMatchQuality,
41                                   &XCore_JITMatchQuality);
42 }
43