b2745008aff154e5bc9db860e41c922e18b916d3
[oota-llvm.git] / lib / Target / ARM / ARMTargetMachine.h
1 //===-- ARMTargetMachine.h - Define TargetMachine for ARM -------*- C++ -*-===//
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 // This file declares the ARM specific subclass of TargetMachine.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef ARMTARGETMACHINE_H
15 #define ARMTARGETMACHINE_H
16
17 #include "llvm/Target/TargetMachine.h"
18 #include "llvm/Target/TargetData.h"
19 #include "llvm/Target/TargetFrameInfo.h"
20 #include "ARMInstrInfo.h"
21 #include "ARMFrameInfo.h"
22 #include "ARMJITInfo.h"
23 #include "ARMSubtarget.h"
24 #include "ARMISelLowering.h"
25 #include "ThumbInstrInfo.h"
26
27 namespace llvm {
28
29 class Module;
30
31 class ARMBaseTargetMachine : public LLVMTargetMachine {
32 protected:
33   ARMSubtarget        Subtarget;
34
35 private:
36   ARMFrameInfo        FrameInfo;
37   ARMJITInfo          JITInfo;
38   InstrItineraryData  InstrItins;
39   Reloc::Model        DefRelocModel;    // Reloc model before it's overridden.
40
41 protected:
42   // To avoid having target depend on the asmprinter stuff libraries, asmprinter
43   // set this functions to ctor pointer at startup time if they are linked in.
44   typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
45                                             ARMBaseTargetMachine &tm,
46                                             bool verbose);
47   static AsmPrinterCtorFn AsmPrinterCtor;
48
49 public:
50   ARMBaseTargetMachine(const Module &M, const std::string &FS, bool isThumb);
51
52   virtual const ARMFrameInfo     *getFrameInfo() const { return &FrameInfo; }
53   virtual       ARMJITInfo       *getJITInfo()         { return &JITInfo; }
54   virtual const ARMSubtarget  *getSubtargetImpl() const { return &Subtarget; }
55   virtual const InstrItineraryData getInstrItineraryData() const {
56     return InstrItins;
57   }
58
59   static void registerAsmPrinter(AsmPrinterCtorFn F) {
60     AsmPrinterCtor = F;
61   }
62
63   static unsigned getModuleMatchQuality(const Module &M);
64   static unsigned getJITMatchQuality();
65
66   virtual const TargetAsmInfo *createTargetAsmInfo() const;
67
68   // Pass Pipeline Configuration
69   virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
70   virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
71   virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
72   virtual bool addAssemblyEmitter(PassManagerBase &PM,
73                                   CodeGenOpt::Level OptLevel,
74                                   bool Verbose, raw_ostream &Out);
75   virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
76                               bool DumpAsm, MachineCodeEmitter &MCE);
77   virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
78                               bool DumpAsm, JITCodeEmitter &MCE);
79   virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
80                                     CodeGenOpt::Level OptLevel,
81                                     bool DumpAsm,
82                                     MachineCodeEmitter &MCE);
83   virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
84                                     CodeGenOpt::Level OptLevel,
85                                     bool DumpAsm,
86                                     JITCodeEmitter &MCE);
87 };
88
89 /// ARMTargetMachine - ARM target machine.
90 ///
91 class ARMTargetMachine : public ARMBaseTargetMachine {
92   ARMInstrInfo        InstrInfo;
93   const TargetData    DataLayout;       // Calculates type size & alignment
94   ARMTargetLowering   TLInfo;
95 public:
96   ARMTargetMachine(const Module &M, const std::string &FS);
97
98   virtual const ARMRegisterInfo  *getRegisterInfo() const {
99     return &InstrInfo.getRegisterInfo();
100   }
101
102   virtual       ARMTargetLowering *getTargetLowering() const {
103     return const_cast<ARMTargetLowering*>(&TLInfo);
104   }
105
106   virtual const ARMInstrInfo     *getInstrInfo() const { return &InstrInfo; }
107   virtual const TargetData       *getTargetData() const { return &DataLayout; }
108
109   static unsigned getJITMatchQuality();
110   static unsigned getModuleMatchQuality(const Module &M);
111 };
112
113 /// ThumbTargetMachine - Thumb target machine.
114 ///
115 class ThumbTargetMachine : public ARMBaseTargetMachine {
116   ThumbInstrInfo      InstrInfo;
117   const TargetData    DataLayout;       // Calculates type size & alignment
118   ARMTargetLowering   TLInfo;
119 public:
120   ThumbTargetMachine(const Module &M, const std::string &FS);
121
122   virtual const ThumbRegisterInfo  *getRegisterInfo() const {
123     return &InstrInfo.getRegisterInfo();
124   }
125
126   virtual       ARMTargetLowering *getTargetLowering() const {
127     return const_cast<ARMTargetLowering*>(&TLInfo);
128   }
129
130   virtual const ThumbInstrInfo   *getInstrInfo() const { return &InstrInfo; }
131   virtual const TargetData       *getTargetData() const { return &DataLayout; }
132
133   static unsigned getJITMatchQuality();
134   static unsigned getModuleMatchQuality(const Module &M);
135 };
136
137 } // end namespace llvm
138
139 #endif