]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/lib/Target/XCore/XCoreTargetMachine.cpp
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / lib / Target / XCore / XCoreTargetMachine.cpp
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/CodeGen/Passes.h"
16 #include "llvm/IR/Module.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/Support/TargetRegistry.h"
19 using namespace llvm;
20
21 /// XCoreTargetMachine ctor - Create an ILP32 architecture model
22 ///
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     DL("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   initAsmInfo();
37 }
38
39 namespace {
40 /// XCore Code Generator Pass Configuration Options.
41 class XCorePassConfig : public TargetPassConfig {
42 public:
43   XCorePassConfig(XCoreTargetMachine *TM, PassManagerBase &PM)
44     : TargetPassConfig(TM, PM) {}
45
46   XCoreTargetMachine &getXCoreTargetMachine() const {
47     return getTM<XCoreTargetMachine>();
48   }
49
50   virtual bool addPreISel();
51   virtual bool addInstSelector();
52 };
53 } // namespace
54
55 TargetPassConfig *XCoreTargetMachine::createPassConfig(PassManagerBase &PM) {
56   return new XCorePassConfig(this, PM);
57 }
58
59 bool XCorePassConfig::addPreISel() {
60   addPass(createXCoreLowerThreadLocalPass());
61   return false;
62 }
63
64 bool XCorePassConfig::addInstSelector() {
65   addPass(createXCoreISelDag(getXCoreTargetMachine(), getOptLevel()));
66   return false;
67 }
68
69 // Force static initialization.
70 extern "C" void LLVMInitializeXCoreTarget() {
71   RegisterTargetMachine<XCoreTargetMachine> X(TheXCoreTarget);
72 }
73
74 void XCoreTargetMachine::addAnalysisPasses(PassManagerBase &PM) {
75   // Add first the target-independent BasicTTI pass, then our XCore pass. This
76   // allows the XCore pass to delegate to the target independent layer when
77   // appropriate.
78   PM.add(createBasicTargetTransformInfoPass(this));
79   PM.add(createXCoreTargetTransformInfoPass(this));
80 }