2009-05-03 20:57:15 +08:00
|
|
|
//===-- MSP430TargetMachine.cpp - Define TargetMachine for MSP430 ---------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Top-level implementation for the MSP430 target.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "MSP430.h"
|
|
|
|
#include "MSP430TargetMachine.h"
|
|
|
|
#include "llvm/PassManager.h"
|
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2009-08-23 04:48:53 +08:00
|
|
|
#include "llvm/MC/MCAsmInfo.h"
|
2009-08-15 03:06:50 +08:00
|
|
|
#include "llvm/Target/TargetRegistry.h"
|
2009-05-03 20:57:15 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2009-08-15 03:06:50 +08:00
|
|
|
extern "C" void LLVMInitializeMSP430Target() {
|
|
|
|
// Register the target.
|
|
|
|
RegisterTargetMachine<MSP430TargetMachine> X(TheMSP430Target);
|
|
|
|
}
|
|
|
|
|
2009-07-16 04:24:03 +08:00
|
|
|
MSP430TargetMachine::MSP430TargetMachine(const Target &T,
|
2009-08-03 07:37:13 +08:00
|
|
|
const std::string &TT,
|
2011-06-30 09:53:36 +08:00
|
|
|
const std::string &CPU,
|
2010-11-15 08:06:54 +08:00
|
|
|
const std::string &FS)
|
2011-07-08 09:53:10 +08:00
|
|
|
: LLVMTargetMachine(T, TT, CPU, FS),
|
2011-06-30 09:53:36 +08:00
|
|
|
Subtarget(TT, CPU, FS),
|
2010-11-15 08:06:54 +08:00
|
|
|
// FIXME: Check TargetData string.
|
|
|
|
DataLayout("e-p:16:16:16-i8:8:8-i16:16:16-i32:16:32-n8:16"),
|
|
|
|
InstrInfo(*this), TLInfo(*this), TSInfo(*this),
|
2011-01-10 20:39:04 +08:00
|
|
|
FrameLowering(Subtarget) { }
|
2009-05-03 20:57:15 +08:00
|
|
|
|
|
|
|
|
2009-05-03 21:19:42 +08:00
|
|
|
bool MSP430TargetMachine::addInstSelector(PassManagerBase &PM,
|
|
|
|
CodeGenOpt::Level OptLevel) {
|
2009-05-03 20:57:15 +08:00
|
|
|
// Install an instruction selector.
|
2009-05-03 21:19:42 +08:00
|
|
|
PM.add(createMSP430ISelDag(*this, OptLevel));
|
2009-05-03 20:57:15 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-01-16 05:19:05 +08:00
|
|
|
bool MSP430TargetMachine::addPreEmitPass(PassManagerBase &PM,
|
|
|
|
CodeGenOpt::Level OptLevel) {
|
|
|
|
// Must run branch selection immediately preceding the asm printer.
|
|
|
|
PM.add(createMSP430BranchSelectionPass());
|
|
|
|
return false;
|
|
|
|
}
|