1 //===-- MSP430TargetMachine.cpp - Define TargetMachine for MSP430 ---------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Top-level implementation for the MSP430 target.
12 //===----------------------------------------------------------------------===//
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"
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
30 extern "C" int MSP430TargetMachineModule;
31 int MSP430TargetMachineModule = 0;
34 // Register the targets
35 static RegisterTarget<MSP430TargetMachine>
36 X("msp430", "MSP430 [experimental]");
38 // Force static initialization.
39 extern "C" void LLVMInitializeMSP430Target() { }
41 MSP430TargetMachine::MSP430TargetMachine(const Module &M,
42 const std::string &FS) :
43 Subtarget(*this, M, FS),
44 // FIXME: Check TargetData string.
45 DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"),
46 InstrInfo(*this), TLInfo(*this),
47 FrameInfo(TargetFrameInfo::StackGrowsDown, 2, -2) { }
49 const TargetAsmInfo *MSP430TargetMachine::createTargetAsmInfo() const {
50 return new MSP430TargetAsmInfo(*this);
53 bool MSP430TargetMachine::addInstSelector(PassManagerBase &PM,
54 CodeGenOpt::Level OptLevel) {
55 // Install an instruction selector.
56 PM.add(createMSP430ISelDag(*this, OptLevel));
60 bool MSP430TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
61 CodeGenOpt::Level OptLevel,
64 // Output assembly language.
65 PM.add(createMSP430CodePrinterPass(Out, *this, Verbose));
69 unsigned MSP430TargetMachine::getModuleMatchQuality(const Module &M) {
70 std::string TT = M.getTargetTriple();
72 // We strongly match msp430
73 if (TT.size() >= 6 && TT[0] == 'm' && TT[1] == 's' && TT[2] == 'p' &&
74 TT[3] == '4' && TT[4] == '3' && TT[5] == '0')