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 "XCoreTargetMachine.h"
14 #include "XCore.h"
15 #include "llvm/Module.h"
16 #include "llvm/PassManager.h"
17 #include "llvm/CodeGen/Passes.h"
18 #include "llvm/Support/TargetRegistry.h"
19 using namespace llvm;
20
21 /// XCoreTargetMachine ctor - Create an ILP32 architecture model
22 ///
XCoreTargetMachine(const Target & T,StringRef TT,StringRef CPU,StringRef FS,const TargetOptions & Options,Reloc::Model RM,CodeModel::Model CM,CodeGenOpt::Level OL)23 XCoreTargetMachine::XCoreTargetMachine(const Target &T, StringRef TT,
24 StringRef CPU, StringRef FS,
25 const TargetOptions &Options,
26 Reloc::Model RM, CodeModel::Model CM,
27 CodeGenOpt::Level OL)
28 : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
29 Subtarget(TT, CPU, FS),
30 DataLayout("e-p:32:32:32-a0:0:32-f32:32:32-f64:32:32-i1:8:32-i8:8:32-"
31 "i16:16:32-i32:32:32-i64:32:32-n32"),
32 InstrInfo(),
33 FrameLowering(Subtarget),
34 TLInfo(*this),
35 TSInfo(*this) {
36 }
37
38 namespace {
39 /// XCore Code Generator Pass Configuration Options.
40 class XCorePassConfig : public TargetPassConfig {
41 public:
XCorePassConfig(XCoreTargetMachine * TM,PassManagerBase & PM)42 XCorePassConfig(XCoreTargetMachine *TM, PassManagerBase &PM)
43 : TargetPassConfig(TM, PM) {}
44
getXCoreTargetMachine() const45 XCoreTargetMachine &getXCoreTargetMachine() const {
46 return getTM<XCoreTargetMachine>();
47 }
48
49 virtual bool addInstSelector();
50 };
51 } // namespace
52
createPassConfig(PassManagerBase & PM)53 TargetPassConfig *XCoreTargetMachine::createPassConfig(PassManagerBase &PM) {
54 return new XCorePassConfig(this, PM);
55 }
56
addInstSelector()57 bool XCorePassConfig::addInstSelector() {
58 addPass(createXCoreISelDag(getXCoreTargetMachine(), getOptLevel()));
59 return false;
60 }
61
62 // Force static initialization.
LLVMInitializeXCoreTarget()63 extern "C" void LLVMInitializeXCoreTarget() {
64 RegisterTargetMachine<XCoreTargetMachine> X(TheXCoreTarget);
65 }
66