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