1 //===-- XCoreTargetMachine.cpp - Define TargetMachine for XCore -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 #include "XCoreTargetAsmInfo.h"
14 #include "XCoreTargetMachine.h"
16 #include "llvm/Module.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/Target/TargetMachineRegistry.h"
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
26 extern "C" int XCoreTargetMachineModule;
27 int XCoreTargetMachineModule = 0;
29 extern Target TheXCoreTarget;
31 // Register the target.
32 RegisterTarget<XCoreTargetMachine> X(TheXCoreTarget, "xcore", "XCore");
35 // Force static initialization.
36 extern "C" void LLVMInitializeXCoreTarget() { }
38 const TargetAsmInfo *XCoreTargetMachine::createTargetAsmInfo() const {
39 return new XCoreTargetAsmInfo(*this);
42 /// XCoreTargetMachine ctor - Create an ILP32 architecture model
44 XCoreTargetMachine::XCoreTargetMachine(const Module &M, const std::string &FS)
45 : Subtarget(*this, M, FS),
46 DataLayout("e-p:32:32:32-a0:0:32-f32:32:32-f64:32:32-i1:8:32-i8:8:32-"
47 "i16:16:32-i32:32:32-i64:32:32"),
53 unsigned XCoreTargetMachine::getModuleMatchQuality(const Module &M) {
54 std::string TT = M.getTargetTriple();
55 if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "xcore-")
58 // Otherwise we don't match.
62 bool XCoreTargetMachine::addInstSelector(PassManagerBase &PM,
63 CodeGenOpt::Level OptLevel) {
64 PM.add(createXCoreISelDag(*this));
68 bool XCoreTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
69 CodeGenOpt::Level OptLevel,
71 formatted_raw_ostream &Out) {
72 // Output assembly language.
73 PM.add(createXCoreCodePrinterPass(Out, *this, Verbose));