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 "MSP430.h"
|
|
|
|
#include "MSP430TargetAsmInfo.h"
|
|
|
|
#include "MSP430TargetMachine.h"
|
|
|
|
#include "llvm/Module.h"
|
|
|
|
#include "llvm/PassManager.h"
|
|
|
|
#include "llvm/CodeGen/Passes.h"
|
|
|
|
#include "llvm/Target/TargetAsmInfo.h"
|
|
|
|
#include "llvm/Target/TargetMachineRegistry.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
/// MSP430TargetMachineModule - Note that this is used on hosts that
|
|
|
|
/// cannot link in a library unless there are references into the
|
|
|
|
/// library. In particular, it seems that it is not possible to get
|
|
|
|
/// things to work on Win32 without this. Though it is unused, do not
|
|
|
|
/// remove it.
|
|
|
|
extern "C" int MSP430TargetMachineModule;
|
|
|
|
int MSP430TargetMachineModule = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// Register the targets
|
|
|
|
static RegisterTarget<MSP430TargetMachine>
|
|
|
|
X("msp430", "MSP430 [experimental]");
|
|
|
|
|
2009-06-23 23:59:40 +00:00
|
|
|
// Force static initialization.
|
|
|
|
extern "C" void LLVMInitializeMSP430Target() { }
|
2009-06-16 20:12:29 +00:00
|
|
|
|
2009-05-03 12:57:15 +00:00
|
|
|
MSP430TargetMachine::MSP430TargetMachine(const Module &M,
|
|
|
|
const std::string &FS) :
|
|
|
|
Subtarget(*this, M, FS),
|
2009-05-03 12:58:05 +00:00
|
|
|
// FIXME: Check TargetData string.
|
2009-05-03 12:57:15 +00:00
|
|
|
DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"),
|
|
|
|
InstrInfo(*this), TLInfo(*this),
|
2009-05-03 13:11:20 +00:00
|
|
|
FrameInfo(TargetFrameInfo::StackGrowsDown, 2, -2) { }
|
2009-05-03 12:57:15 +00:00
|
|
|
|
|
|
|
const TargetAsmInfo *MSP430TargetMachine::createTargetAsmInfo() const {
|
|
|
|
return new MSP430TargetAsmInfo(*this);
|
|
|
|
}
|
|
|
|
|
2009-05-03 13:19:42 +00:00
|
|
|
bool MSP430TargetMachine::addInstSelector(PassManagerBase &PM,
|
|
|
|
CodeGenOpt::Level OptLevel) {
|
2009-05-03 12:57:15 +00:00
|
|
|
// Install an instruction selector.
|
2009-05-03 13:19:42 +00:00
|
|
|
PM.add(createMSP430ISelDag(*this, OptLevel));
|
2009-05-03 12:57:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-05-03 13:01:23 +00:00
|
|
|
bool MSP430TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
|
2009-05-03 13:19:42 +00:00
|
|
|
CodeGenOpt::Level OptLevel,
|
|
|
|
bool Verbose,
|
2009-05-03 13:01:23 +00:00
|
|
|
raw_ostream &Out) {
|
2009-05-03 12:57:15 +00:00
|
|
|
// Output assembly language.
|
2009-07-01 01:48:54 +00:00
|
|
|
PM.add(createMSP430CodePrinterPass(Out, *this, Verbose));
|
2009-05-03 12:57:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-05-03 13:01:23 +00:00
|
|
|
|
|
|
|
unsigned MSP430TargetMachine::getModuleMatchQuality(const Module &M) {
|
|
|
|
std::string TT = M.getTargetTriple();
|
|
|
|
|
|
|
|
// We strongly match msp430
|
|
|
|
if (TT.size() >= 6 && TT[0] == 'm' && TT[1] == 's' && TT[2] == 'p' &&
|
|
|
|
TT[3] == '4' && TT[4] == '3' && TT[5] == '0')
|
|
|
|
return 20;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|