Reapply the TargerTransformInfo changes, minus the changes to LSR and Lowerinvoke.
[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 "ARMInstrInfo.h"
18 #include "ARMELFWriterInfo.h"
19 #include "ARMFrameLowering.h"
20 #include "ARMJITInfo.h"
21 #include "ARMSubtarget.h"
22 #include "ARMISelLowering.h"
23 #include "ARMSelectionDAGInfo.h"
24 #include "Thumb1InstrInfo.h"
25 #include "Thumb1FrameLowering.h"
26 #include "Thumb2InstrInfo.h"
27 #include "llvm/Target/TargetMachine.h"
28 #include "llvm/Target/TargetTransformImpl.h"
29 #include "llvm/DataLayout.h"
30 #include "llvm/MC/MCStreamer.h"
31 #include "llvm/ADT/OwningPtr.h"
32
33 namespace llvm {
34
35 class ARMBaseTargetMachine : public LLVMTargetMachine {
36 protected:
37   ARMSubtarget        Subtarget;
38 private:
39   ARMJITInfo          JITInfo;
40   InstrItineraryData  InstrItins;
41
42 public:
43   ARMBaseTargetMachine(const Target &T, StringRef TT,
44                        StringRef CPU, StringRef FS,
45                        const TargetOptions &Options,
46                        Reloc::Model RM, CodeModel::Model CM,
47                        CodeGenOpt::Level OL);
48
49   virtual       ARMJITInfo       *getJITInfo()         { return &JITInfo; }
50   virtual const ARMSubtarget  *getSubtargetImpl() const { return &Subtarget; }
51   virtual const InstrItineraryData *getInstrItineraryData() const {
52     return &InstrItins;
53   }
54
55   // Pass Pipeline Configuration
56   virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
57
58   virtual bool addCodeEmitter(PassManagerBase &PM, JITCodeEmitter &MCE);
59 };
60
61 /// ARMTargetMachine - ARM target machine.
62 ///
63 class ARMTargetMachine : public ARMBaseTargetMachine {
64   virtual void anchor();
65   ARMInstrInfo        InstrInfo;
66   const DataLayout    DL;       // Calculates type size & alignment
67   ARMELFWriterInfo    ELFWriterInfo;
68   ARMTargetLowering   TLInfo;
69   ARMSelectionDAGInfo TSInfo;
70   ARMFrameLowering    FrameLowering;
71   ScalarTargetTransformImpl STTI;
72   VectorTargetTransformImpl VTTI;
73  public:
74   ARMTargetMachine(const Target &T, StringRef TT,
75                    StringRef CPU, StringRef FS,
76                    const TargetOptions &Options,
77                    Reloc::Model RM, CodeModel::Model CM,
78                    CodeGenOpt::Level OL);
79
80   virtual const ARMRegisterInfo  *getRegisterInfo() const {
81     return &InstrInfo.getRegisterInfo();
82   }
83
84   virtual const ARMTargetLowering *getTargetLowering() const {
85     return &TLInfo;
86   }
87
88   virtual const ARMSelectionDAGInfo* getSelectionDAGInfo() const {
89     return &TSInfo;
90   }
91   virtual const ARMFrameLowering *getFrameLowering() const {
92     return &FrameLowering;
93   }
94   virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const {
95     return &STTI;
96   }
97   virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const {
98     return &VTTI;
99   }
100   virtual const ARMInstrInfo     *getInstrInfo() const { return &InstrInfo; }
101   virtual const DataLayout       *getDataLayout() const { return &DL; }
102   virtual const ARMELFWriterInfo *getELFWriterInfo() const {
103     return Subtarget.isTargetELF() ? &ELFWriterInfo : 0;
104   }
105 };
106
107 /// ThumbTargetMachine - Thumb target machine.
108 /// Due to the way architectures are handled, this represents both
109 ///   Thumb-1 and Thumb-2.
110 ///
111 class ThumbTargetMachine : public ARMBaseTargetMachine {
112   virtual void anchor();
113   // Either Thumb1InstrInfo or Thumb2InstrInfo.
114   OwningPtr<ARMBaseInstrInfo> InstrInfo;
115   const DataLayout    DL;   // Calculates type size & alignment
116   ARMELFWriterInfo    ELFWriterInfo;
117   ARMTargetLowering   TLInfo;
118   ARMSelectionDAGInfo TSInfo;
119   // Either Thumb1FrameLowering or ARMFrameLowering.
120   OwningPtr<ARMFrameLowering> FrameLowering;
121   ScalarTargetTransformImpl STTI;
122   VectorTargetTransformImpl VTTI;
123 public:
124   ThumbTargetMachine(const Target &T, StringRef TT,
125                      StringRef CPU, StringRef FS,
126                      const TargetOptions &Options,
127                      Reloc::Model RM, CodeModel::Model CM,
128                      CodeGenOpt::Level OL);
129
130   /// returns either Thumb1RegisterInfo or Thumb2RegisterInfo
131   virtual const ARMBaseRegisterInfo *getRegisterInfo() const {
132     return &InstrInfo->getRegisterInfo();
133   }
134
135   virtual const ARMTargetLowering *getTargetLowering() const {
136     return &TLInfo;
137   }
138
139   virtual const ARMSelectionDAGInfo *getSelectionDAGInfo() const {
140     return &TSInfo;
141   }
142
143   /// returns either Thumb1InstrInfo or Thumb2InstrInfo
144   virtual const ARMBaseInstrInfo *getInstrInfo() const {
145     return InstrInfo.get();
146   }
147   /// returns either Thumb1FrameLowering or ARMFrameLowering
148   virtual const ARMFrameLowering *getFrameLowering() const {
149     return FrameLowering.get();
150   }
151   virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const {
152     return &STTI;
153   }
154   virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const {
155     return &VTTI;
156   }
157   virtual const DataLayout       *getDataLayout() const { return &DL; }
158   virtual const ARMELFWriterInfo *getELFWriterInfo() const {
159     return Subtarget.isTargetELF() ? &ELFWriterInfo : 0;
160   }
161 };
162
163 } // end namespace llvm
164
165 #endif