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" 19 using 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. 26 extern "C" int XCoreTargetMachineModule; 27 int XCoreTargetMachineModule = 0; 28 29 namespace { 30 // Register the target. 31 RegisterTarget<XCoreTargetMachine> X("xcore", "XCore"); 32 } 33 34 // Force static initialization. 35 extern "C" void LLVMInitializeXCoreTarget() { } 36 37 const TargetAsmInfo *XCoreTargetMachine::createTargetAsmInfo() const { 38 return new XCoreTargetAsmInfo(*this); 39 } 40 41 /// XCoreTargetMachine ctor - Create an ILP32 architecture model 42 /// 43 XCoreTargetMachine::XCoreTargetMachine(const Module &M, const std::string &FS) 44 : Subtarget(*this, M, FS), 45 DataLayout("e-p:32:32:32-a0:0:32-f32:32:32-f64:32:32-i1:8:32-i8:8:32-" 46 "i16:16:32-i32:32:32-i64:32:32"), 47 InstrInfo(), 48 FrameInfo(*this), 49 TLInfo(*this) { 50 } 51 52 unsigned XCoreTargetMachine::getModuleMatchQuality(const Module &M) { 53 std::string TT = M.getTargetTriple(); 54 if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "xcore-") 55 return 20; 56 57 // Otherwise we don't match. 58 return 0; 59 } 60 61 bool XCoreTargetMachine::addInstSelector(PassManagerBase &PM, 62 CodeGenOpt::Level OptLevel) { 63 PM.add(createXCoreISelDag(*this)); 64 return false; 65 } 66 67 bool XCoreTargetMachine::addAssemblyEmitter(PassManagerBase &PM, 68 CodeGenOpt::Level OptLevel, 69 bool Verbose, 70 raw_ostream &Out) { 71 // Output assembly language. 72 PM.add(createXCoreCodePrinterPass(Out, *this, Verbose)); 73 return false; 74 } 75