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.
11 //
12 //===----------------------------------------------------------------------===//
13 
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"
22 
23 using namespace llvm;
24 
25 // Register the targets
26 static RegisterTarget<MSP430TargetMachine>
27 X(TheMSP430Target, "msp430", "MSP430 [experimental]");
28 
29 // Force static initialization.
30 extern "C" void LLVMInitializeMSP430Target() {
31   TargetRegistry::RegisterAsmPrinter(TheMSP430Target,
32                                      &createMSP430CodePrinterPass);
33 }
34 
35 MSP430TargetMachine::MSP430TargetMachine(const Target &T,
36                                          const Module &M,
37                                          const std::string &FS) :
38   LLVMTargetMachine(T),
39   Subtarget(*this, M, FS),
40   // FIXME: Check TargetData string.
41   DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"),
42   InstrInfo(*this), TLInfo(*this),
43   FrameInfo(TargetFrameInfo::StackGrowsDown, 2, -2) { }
44 
45 const TargetAsmInfo *MSP430TargetMachine::createTargetAsmInfo() const {
46   return new MSP430TargetAsmInfo(*this);
47 }
48 
49 bool MSP430TargetMachine::addInstSelector(PassManagerBase &PM,
50                                           CodeGenOpt::Level OptLevel) {
51   // Install an instruction selector.
52   PM.add(createMSP430ISelDag(*this, OptLevel));
53   return false;
54 }
55 
56