Match wrapper node for address
[llvm/msp430.git] / lib / Target / MSP430 / MSP430TargetMachine.cpp
bloba2dee33c6c9e988357ebaa104f858f3e46815a51
1 //===-- MSP430TargetMachine.cpp - Define TargetMachine for MSP430 ---------===//
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 // Top-level implementation for the MSP430 target.
12 //===----------------------------------------------------------------------===//
14 #include "MSP430.h"
15 #include "MSP430TargetAsmInfo.h"
16 #include "MSP430TargetMachine.h"
17 #include "llvm/Module.h"
18 #include "llvm/PassManager.h"
19 #include "llvm/CodeGen/Passes.h"
20 #include "llvm/Target/TargetAsmInfo.h"
21 #include "llvm/Target/TargetMachineRegistry.h"
23 using namespace llvm;
25 /// MSP430TargetMachineModule - Note that this is used on hosts that
26 /// cannot link in a library unless there are references into the
27 /// library. In particular, it seems that it is not possible to get
28 /// things to work on Win32 without this. Though it is unused, do not
29 /// remove it.
30 extern "C" int MSP430TargetMachineModule;
31 int MSP430TargetMachineModule = 0;
34 // Register the targets
35 static RegisterTarget<MSP430TargetMachine>
36 X("msp430", "MSP430 [experimental]");
38 MSP430TargetMachine::MSP430TargetMachine(const Module &M,
39 const std::string &FS) :
40 Subtarget(*this, M, FS),
41 // FIXME: Check TargetData string.
42 DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"),
43 InstrInfo(*this), TLInfo(*this),
44 FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0) { }
46 const TargetAsmInfo *MSP430TargetMachine::createTargetAsmInfo() const {
47 return new MSP430TargetAsmInfo(*this);
50 bool MSP430TargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) {
51 // Install an instruction selector.
52 PM.add(createMSP430ISelDag(*this));
53 return false;
56 bool MSP430TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
57 bool Fast, bool Verbose,
58 raw_ostream &Out) {
59 // Output assembly language.
60 PM.add(createMSP430CodePrinterPass(Out, *this, Fast, Verbose));
61 return false;
64 unsigned MSP430TargetMachine::getModuleMatchQuality(const Module &M) {
65 std::string TT = M.getTargetTriple();
67 // We strongly match msp430
68 if (TT.size() >= 6 && TT[0] == 'm' && TT[1] == 's' && TT[2] == 'p' &&
69 TT[3] == '4' && TT[4] == '3' && TT[5] == '0')
70 return 20;
72 return 0;