MSP430TargetInfo.cpp revision 4cb1e13769856716261a4d315f8202bd918502c3
1//===-- MSP430TargetInfo.cpp - MSP430 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 "MSP430.h"
11#include "llvm/Module.h"
12#include "llvm/Target/TargetRegistry.h"
13using namespace llvm;
14
15Target llvm::TheMSP430Target;
16
17static unsigned MSP430_JITMatchQuality() {
18  return 0;
19}
20
21static unsigned MSP430_TripleMatchQuality(const std::string &TT) {
22  // We strongly match msp430
23  if (TT.size() >= 6 && TT[0] == 'm' && TT[1] == 's' && TT[2] == 'p' &&
24      TT[3] == '4' &&  TT[4] == '3' && TT[5] == '0')
25    return 20;
26
27  return 0;
28}
29
30static unsigned MSP430_ModuleMatchQuality(const Module &M) {
31  // Check for a triple match.
32  if (unsigned Q = MSP430_TripleMatchQuality(M.getTargetTriple()))
33    return Q;
34
35  // Otherwise if the target triple is non-empty, we don't match.
36  if (!M.getTargetTriple().empty()) return 0;
37
38  return 0;
39}
40
41extern "C" void LLVMInitializeMSP430TargetInfo() {
42  TargetRegistry::RegisterTarget(TheMSP430Target, "msp430",
43                                  "MSP430 [experimental]",
44                                  &MSP430_TripleMatchQuality,
45                                  &MSP430_ModuleMatchQuality,
46                                  &MSP430_JITMatchQuality);
47}
48