blob: 8b3e1f42a2496bba5c6635367997e7ec035950f6 [file] [log] [blame]
Daniel Dunbar0eb66992009-07-15 06:35:19 +00001//===-- 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
Daniel Dunbar0b0441e2009-07-18 23:03:22 +000010#include "MSP430.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::TheMSP430Target;
Daniel Dunbar0eb66992009-07-15 06:35:19 +000016
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}