Kill off old (TargetMachine level, not Target level) match quality functions.
[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 "ARMInstrInfo.h"
20 #include "ARMFrameInfo.h"
21 #include "ARMJITInfo.h"
22 #include "ARMSubtarget.h"
23 #include "ARMISelLowering.h"
24 #include "Thumb1InstrInfo.h"
25 #include "Thumb2InstrInfo.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)(formatted_raw_ostream &o,
45                                             TargetMachine &tm,
46                                             bool verbose);
47   static AsmPrinterCtorFn AsmPrinterCtor;
48
49 public:
50   ARMBaseTargetMachine(const Target &T, const Module &M, const std::string &FS, 
51                        bool isThumb);
52
53   virtual const ARMFrameInfo     *getFrameInfo() const { return &FrameInfo; }
54   virtual       ARMJITInfo       *getJITInfo()         { return &JITInfo; }
55   virtual const ARMSubtarget  *getSubtargetImpl() const { return &Subtarget; }
56   virtual const InstrItineraryData getInstrItineraryData() const {
57     return InstrItins;
58   }
59
60   static void registerAsmPrinter(AsmPrinterCtorFn F) {
61     AsmPrinterCtor = F;
62   }
63
64   virtual const TargetAsmInfo *createTargetAsmInfo() const;
65
66   // Pass Pipeline Configuration
67   virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
68   virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
69   virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
70   virtual bool addAssemblyEmitter(PassManagerBase &PM,
71                                   CodeGenOpt::Level OptLevel,
72                                   bool Verbose, formatted_raw_ostream &Out);
73   virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
74                               bool DumpAsm, MachineCodeEmitter &MCE);
75   virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
76                               bool DumpAsm, JITCodeEmitter &MCE);
77   virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
78                               bool DumpAsm, ObjectCodeEmitter &OCE);
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   virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
88                                     CodeGenOpt::Level OptLevel,
89                                     bool DumpAsm,
90                                     ObjectCodeEmitter &OCE);
91 };
92
93 /// ARMTargetMachine - ARM target machine.
94 ///
95 class ARMTargetMachine : public ARMBaseTargetMachine {
96   ARMInstrInfo        InstrInfo;
97   const TargetData    DataLayout;       // Calculates type size & alignment
98   ARMTargetLowering   TLInfo;
99 public:
100   ARMTargetMachine(const Target &T, const Module &M, const std::string &FS);
101
102   virtual const ARMRegisterInfo  *getRegisterInfo() const {
103     return &InstrInfo.getRegisterInfo();
104   }
105
106   virtual       ARMTargetLowering *getTargetLowering() const {
107     return const_cast<ARMTargetLowering*>(&TLInfo);
108   }
109
110   virtual const ARMInstrInfo     *getInstrInfo() const { return &InstrInfo; }
111   virtual const TargetData       *getTargetData() const { return &DataLayout; }
112
113   static unsigned getJITMatchQuality();
114   static unsigned getModuleMatchQuality(const Module &M);
115 };
116
117 /// ThumbTargetMachine - Thumb target machine.
118 /// Due to the way architectures are handled, this represents both
119 ///   Thumb-1 and Thumb-2.
120 ///
121 class ThumbTargetMachine : public ARMBaseTargetMachine {
122   ARMBaseInstrInfo    *InstrInfo;   // either Thumb1InstrInfo or Thumb2InstrInfo
123   const TargetData    DataLayout;   // Calculates type size & alignment
124   ARMTargetLowering   TLInfo;
125 public:
126   ThumbTargetMachine(const Target &T, const Module &M, const std::string &FS);
127
128   /// returns either Thumb1RegisterInfo of Thumb2RegisterInfo
129   virtual const ARMBaseRegisterInfo *getRegisterInfo() const {
130     return &InstrInfo->getRegisterInfo();
131   }
132
133   virtual ARMTargetLowering *getTargetLowering() const {
134     return const_cast<ARMTargetLowering*>(&TLInfo);
135   }
136
137   /// returns either Thumb1InstrInfo or Thumb2InstrInfo
138   virtual const ARMBaseInstrInfo *getInstrInfo() const { return InstrInfo; }
139   virtual const TargetData       *getTargetData() const { return &DataLayout; }
140
141   static unsigned getJITMatchQuality();
142   static unsigned getModuleMatchQuality(const Module &M);
143 };
144
145 } // end namespace llvm
146
147 #endif