blob: ffd93da921a54b5645b0677d796693db143476e3 [file] [log] [blame]
Anton Korobeynikov37171572009-05-03 12:57:15 +00001//===-- 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
23using namespace llvm;
24
Anton Korobeynikov37171572009-05-03 12:57:15 +000025// Register the targets
26static RegisterTarget<MSP430TargetMachine>
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000027X(TheMSP430Target, "msp430", "MSP430 [experimental]");
Anton Korobeynikov37171572009-05-03 12:57:15 +000028
Bob Wilsonebbc1c42009-06-23 23:59:40 +000029// Force static initialization.
Daniel Dunbar946686a2009-07-15 23:17:20 +000030extern "C" void LLVMInitializeMSP430Target() {
31 TargetRegistry::RegisterAsmPrinter(TheMSP430Target,
32 &createMSP430CodePrinterPass);
33}
Douglas Gregor1dc5ff42009-06-16 20:12:29 +000034
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000035MSP430TargetMachine::MSP430TargetMachine(const Target &T,
36 const Module &M,
Anton Korobeynikov37171572009-05-03 12:57:15 +000037 const std::string &FS) :
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000038 LLVMTargetMachine(T),
Anton Korobeynikov37171572009-05-03 12:57:15 +000039 Subtarget(*this, M, FS),
Anton Korobeynikov82f38642009-05-03 12:58:05 +000040 // FIXME: Check TargetData string.
Anton Korobeynikov37171572009-05-03 12:57:15 +000041 DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"),
42 InstrInfo(*this), TLInfo(*this),
Anton Korobeynikovaeafc4f2009-05-03 13:11:20 +000043 FrameInfo(TargetFrameInfo::StackGrowsDown, 2, -2) { }
Anton Korobeynikov37171572009-05-03 12:57:15 +000044
Anton Korobeynikov37171572009-05-03 12:57:15 +000045const TargetAsmInfo *MSP430TargetMachine::createTargetAsmInfo() const {
46 return new MSP430TargetAsmInfo(*this);
47}
48
Anton Korobeynikov0d370dc2009-05-03 13:19:42 +000049bool MSP430TargetMachine::addInstSelector(PassManagerBase &PM,
50 CodeGenOpt::Level OptLevel) {
Anton Korobeynikov37171572009-05-03 12:57:15 +000051 // Install an instruction selector.
Anton Korobeynikov0d370dc2009-05-03 13:19:42 +000052 PM.add(createMSP430ISelDag(*this, OptLevel));
Anton Korobeynikov37171572009-05-03 12:57:15 +000053 return false;
54}
55