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"
|
2015-01-14 19:23:27 +08:00
|
|
|
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
|
2015-02-13 18:01:29 +08:00
|
|
|
#include "llvm/IR/LegacyPassManager.h"
|
2009-08-23 04:48:53 +08:00
|
|
|
#include "llvm/MC/MCAsmInfo.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);
|
|
|
|
}
|
|
|
|
|
2015-06-12 03:41:26 +08:00
|
|
|
MSP430TargetMachine::MSP430TargetMachine(const Target &T, const Triple &TT,
|
2014-06-27 09:14:54 +08:00
|
|
|
StringRef CPU, 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)
|
2015-03-12 08:07:24 +08:00
|
|
|
: LLVMTargetMachine(T, "e-m:e-p:16:16-i32:16:32-a:16-n8:16", TT, CPU, FS,
|
|
|
|
Options, RM, CM, OL),
|
2014-11-13 17:26:31 +08:00
|
|
|
TLOF(make_unique<TargetLoweringObjectFileELF>()),
|
2015-01-27 03:03:15 +08:00
|
|
|
// FIXME: Check DataLayout string.
|
2015-06-12 03:41:26 +08:00
|
|
|
Subtarget(TT, CPU, FS, *this) {
|
2013-05-13 09:16:13 +08:00
|
|
|
initAsmInfo();
|
|
|
|
}
|
2009-05-03 20:57:15 +08:00
|
|
|
|
2014-11-21 07:37:18 +08:00
|
|
|
MSP430TargetMachine::~MSP430TargetMachine() {}
|
|
|
|
|
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>();
|
|
|
|
}
|
|
|
|
|
2014-04-29 15:58:09 +08:00
|
|
|
bool addInstSelector() override;
|
2014-12-12 05:26:47 +08:00
|
|
|
void addPreEmitPass() override;
|
2012-02-03 13:12:41 +08:00
|
|
|
};
|
|
|
|
} // 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;
|
|
|
|
}
|
|
|
|
|
2014-12-12 05:26:47 +08:00
|
|
|
void MSP430PassConfig::addPreEmitPass() {
|
2010-01-16 05:19:05 +08:00
|
|
|
// Must run branch selection immediately preceding the asm printer.
|
2014-12-12 05:26:47 +08:00
|
|
|
addPass(createMSP430BranchSelectionPass(), false);
|
2010-01-16 05:19:05 +08:00
|
|
|
}
|