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 "XCoreTargetMachine.h"
15 #include "llvm/CodeGen/Passes.h"
16 #include "llvm/IR/Module.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/Support/TargetRegistry.h"
21 /// XCoreTargetMachine ctor - Create an ILP32 architecture model
23 XCoreTargetMachine::XCoreTargetMachine(const Target &T, StringRef TT,
24 StringRef CPU, StringRef FS,
25 const TargetOptions &Options,
26 Reloc::Model RM, CodeModel::Model CM,
28 : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
29 Subtarget(TT, CPU, FS),
30 DL("e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32"),
32 FrameLowering(Subtarget),
39 /// XCore Code Generator Pass Configuration Options.
40 class XCorePassConfig : public TargetPassConfig {
42 XCorePassConfig(XCoreTargetMachine *TM, PassManagerBase &PM)
43 : TargetPassConfig(TM, PM) {}
45 XCoreTargetMachine &getXCoreTargetMachine() const {
46 return getTM<XCoreTargetMachine>();
49 virtual bool addPreISel();
50 virtual bool addInstSelector();
51 virtual bool addPreEmitPass();
55 TargetPassConfig *XCoreTargetMachine::createPassConfig(PassManagerBase &PM) {
56 return new XCorePassConfig(this, PM);
59 bool XCorePassConfig::addPreISel() {
60 addPass(createXCoreLowerThreadLocalPass());
64 bool XCorePassConfig::addInstSelector() {
65 addPass(createXCoreISelDag(getXCoreTargetMachine(), getOptLevel()));
69 bool XCorePassConfig::addPreEmitPass() {
70 addPass(createXCoreFrameToArgsOffsetEliminationPass());
74 // Force static initialization.
75 extern "C" void LLVMInitializeXCoreTarget() {
76 RegisterTargetMachine<XCoreTargetMachine> X(TheXCoreTarget);
79 void XCoreTargetMachine::addAnalysisPasses(PassManagerBase &PM) {
80 // Add first the target-independent BasicTTI pass, then our XCore pass. This
81 // allows the XCore pass to delegate to the target independent layer when
83 PM.add(createBasicTargetTransformInfoPass(this));
84 PM.add(createXCoreTargetTransformInfoPass(this));