XCoreTargetMachine.cpp revision 1e1f8ba28cc05212dfd347be219daa698d7294a5
1//===-- XCoreTargetMachine.cpp - Define TargetMachine for XCore -----------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// 11//===----------------------------------------------------------------------===// 12 13#include "XCoreTargetAsmInfo.h" 14#include "XCoreTargetMachine.h" 15#include "XCore.h" 16#include "llvm/Module.h" 17#include "llvm/PassManager.h" 18#include "llvm/Target/TargetMachineRegistry.h" 19using namespace llvm; 20 21/// XCoreTargetMachineModule - Note that this is used on hosts that 22/// cannot link in a library unless there are references into the 23/// library. In particular, it seems that it is not possible to get 24/// things to work on Win32 without this. Though it is unused, do not 25/// remove it. 26extern "C" int XCoreTargetMachineModule; 27int XCoreTargetMachineModule = 0; 28 29extern Target TheXCoreTarget; 30namespace { 31 // Register the target. 32 RegisterTarget<XCoreTargetMachine> X(TheXCoreTarget, "xcore", "XCore"); 33} 34 35// Force static initialization. 36extern "C" void LLVMInitializeXCoreTarget() { 37 TargetRegistry::RegisterAsmPrinter(TheXCoreTarget, 38 &createXCoreCodePrinterPass); 39} 40 41const TargetAsmInfo *XCoreTargetMachine::createTargetAsmInfo() const { 42 return new XCoreTargetAsmInfo(*this); 43} 44 45/// XCoreTargetMachine ctor - Create an ILP32 architecture model 46/// 47XCoreTargetMachine::XCoreTargetMachine(const Target &T, const Module &M, 48 const std::string &FS) 49 : LLVMTargetMachine(T), 50 Subtarget(*this, M, FS), 51 DataLayout("e-p:32:32:32-a0:0:32-f32:32:32-f64:32:32-i1:8:32-i8:8:32-" 52 "i16:16:32-i32:32:32-i64:32:32"), 53 InstrInfo(), 54 FrameInfo(*this), 55 TLInfo(*this) { 56} 57 58bool XCoreTargetMachine::addInstSelector(PassManagerBase &PM, 59 CodeGenOpt::Level OptLevel) { 60 PM.add(createXCoreISelDag(*this)); 61 return false; 62} 63 64bool XCoreTargetMachine::addAssemblyEmitter(PassManagerBase &PM, 65 CodeGenOpt::Level OptLevel, 66 bool Verbose, 67 formatted_raw_ostream &Out) { 68 FunctionPass *Printer = getTarget().createAsmPrinter(Out, *this, Verbose); 69 if (!Printer) 70 llvm_report_error("unable to create assembly printer"); 71 PM.add(Printer); 72 return false; 73} 74