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