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 "MSP430TargetMachine.h"
|
2012-03-18 02:46:09 +08:00
|
|
|
#include "MSP430.h"
|
2009-05-03 20:57:15 +08:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2009-08-23 04:48:53 +08:00
|
|
|
#include "llvm/MC/MCAsmInfo.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/PassManager.h"
|
2011-08-25 02:08:43 +08:00
|
|
|
#include "llvm/Support/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,
|
2011-07-19 14:37:02 +08:00
|
|
|
StringRef TT,
|
|
|
|
StringRef CPU,
|
2011-07-20 15:51:56 +08:00
|
|
|
StringRef FS,
|
2011-12-03 06:16:29 +08:00
|
|
|
const TargetOptions &Options,
|
2011-11-16 16:38:26 +08:00
|
|
|
Reloc::Model RM, CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL)
|
2011-12-03 06:16:29 +08:00
|
|
|
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
2011-06-30 09:53:36 +08:00
|
|
|
Subtarget(TT, CPU, FS),
|
2012-10-09 00:38:25 +08:00
|
|
|
// FIXME: Check DataLayout string.
|
|
|
|
DL("e-p:16:16:16-i8:8:8-i16:16:16-i32:16:32-n8:16"),
|
2010-11-15 08:06:54 +08:00
|
|
|
InstrInfo(*this), TLInfo(*this), TSInfo(*this),
|
2013-05-13 09:16:13 +08:00
|
|
|
FrameLowering(Subtarget) {
|
|
|
|
initAsmInfo();
|
|
|
|
}
|
2009-05-03 20:57:15 +08:00
|
|
|
|
2012-02-03 13:12:41 +08:00
|
|
|
namespace {
|
|
|
|
/// MSP430 Code Generator Pass Configuration Options.
|
|
|
|
class MSP430PassConfig : public TargetPassConfig {
|
|
|
|
public:
|
2012-02-04 10:56:59 +08:00
|
|
|
MSP430PassConfig(MSP430TargetMachine *TM, PassManagerBase &PM)
|
|
|
|
: TargetPassConfig(TM, PM) {}
|
2009-05-03 20:57:15 +08:00
|
|
|
|
2012-02-03 13:12:41 +08:00
|
|
|
MSP430TargetMachine &getMSP430TargetMachine() const {
|
|
|
|
return getTM<MSP430TargetMachine>();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool addInstSelector();
|
|
|
|
virtual bool addPreEmitPass();
|
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
2012-02-04 10:56:59 +08:00
|
|
|
TargetPassConfig *MSP430TargetMachine::createPassConfig(PassManagerBase &PM) {
|
|
|
|
return new MSP430PassConfig(this, PM);
|
2012-02-03 13:12:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MSP430PassConfig::addInstSelector() {
|
2009-05-03 20:57:15 +08:00
|
|
|
// Install an instruction selector.
|
2012-07-03 03:48:31 +08:00
|
|
|
addPass(createMSP430ISelDag(getMSP430TargetMachine(), getOptLevel()));
|
2009-05-03 20:57:15 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-03 13:12:41 +08:00
|
|
|
bool MSP430PassConfig::addPreEmitPass() {
|
2010-01-16 05:19:05 +08:00
|
|
|
// Must run branch selection immediately preceding the asm printer.
|
2012-07-03 03:48:31 +08:00
|
|
|
addPass(createMSP430BranchSelectionPass());
|
2010-01-16 05:19:05 +08:00
|
|
|
return false;
|
|
|
|
}
|