[PowerPC] Modern Book-E cores support sync
[oota-llvm.git] / lib / Target / PowerPC / PPCSubtarget.h
1 //===-- PPCSubtarget.h - Define Subtarget for the PPC ----------*- 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 PowerPC specific subclass of TargetSubtargetInfo.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_LIB_TARGET_POWERPC_PPCSUBTARGET_H
15 #define LLVM_LIB_TARGET_POWERPC_PPCSUBTARGET_H
16
17 #include "PPCFrameLowering.h"
18 #include "PPCInstrInfo.h"
19 #include "PPCISelLowering.h"
20 #include "PPCSelectionDAGInfo.h"
21 #include "llvm/ADT/Triple.h"
22 #include "llvm/IR/DataLayout.h"
23 #include "llvm/MC/MCInstrItineraries.h"
24 #include "llvm/Target/TargetSubtargetInfo.h"
25 #include <string>
26
27 #define GET_SUBTARGETINFO_HEADER
28 #include "PPCGenSubtargetInfo.inc"
29
30 // GCC #defines PPC on Linux but we use it as our namespace name
31 #undef PPC
32
33 namespace llvm {
34 class StringRef;
35
36 namespace PPC {
37   // -m directive values.
38   enum {
39     DIR_NONE,
40     DIR_32,
41     DIR_440,
42     DIR_601,
43     DIR_602,
44     DIR_603,
45     DIR_7400,
46     DIR_750,
47     DIR_970,
48     DIR_A2,
49     DIR_E500mc,
50     DIR_E5500,
51     DIR_PWR3,
52     DIR_PWR4,
53     DIR_PWR5,
54     DIR_PWR5X,
55     DIR_PWR6,
56     DIR_PWR6X,
57     DIR_PWR7,
58     DIR_PWR8,
59     DIR_64
60   };
61 }
62
63 class GlobalValue;
64 class TargetMachine;
65
66 class PPCSubtarget : public PPCGenSubtargetInfo {
67 protected:
68   /// TargetTriple - What processor and OS we're targeting.
69   Triple TargetTriple;
70
71   // Calculates type size & alignment
72   const DataLayout DL;
73
74   /// stackAlignment - The minimum alignment known to hold of the stack frame on
75   /// entry to the function and which must be maintained by every function.
76   unsigned StackAlignment;
77
78   /// Selected instruction itineraries (one entry per itinerary class.)
79   InstrItineraryData InstrItins;
80
81   /// Which cpu directive was used.
82   unsigned DarwinDirective;
83
84   /// Used by the ISel to turn in optimizations for POWER4-derived architectures
85   bool HasMFOCRF;
86   bool Has64BitSupport;
87   bool Use64BitRegs;
88   bool UseCRBits;
89   bool IsPPC64;
90   bool HasAltivec;
91   bool HasSPE;
92   bool HasQPX;
93   bool HasVSX;
94   bool HasFCPSGN;
95   bool HasFSQRT;
96   bool HasFRE, HasFRES, HasFRSQRTE, HasFRSQRTES;
97   bool HasRecipPrec;
98   bool HasSTFIWX;
99   bool HasLFIWAX;
100   bool HasFPRND;
101   bool HasFPCVT;
102   bool HasISEL;
103   bool HasPOPCNTD;
104   bool HasLDBRX;
105   bool IsBookE;
106   bool HasOnlyMSYNC;
107   bool IsE500;
108   bool IsPPC4xx;
109   bool IsPPC6xx;
110   bool DeprecatedMFTB;
111   bool DeprecatedDST;
112   bool HasLazyResolverStubs;
113   bool IsLittleEndian;
114
115   enum {
116     PPC_ABI_UNKNOWN,
117     PPC_ABI_ELFv1,
118     PPC_ABI_ELFv2
119   } TargetABI;
120
121   PPCFrameLowering FrameLowering;
122   PPCInstrInfo InstrInfo;
123   PPCTargetLowering TLInfo;
124   PPCSelectionDAGInfo TSInfo;
125
126 public:
127   /// This constructor initializes the data members to match that
128   /// of the specified triple.
129   ///
130   PPCSubtarget(const std::string &TT, const std::string &CPU,
131                const std::string &FS, const PPCTargetMachine &TM);
132
133   /// ParseSubtargetFeatures - Parses features string setting specified
134   /// subtarget options.  Definition of function is auto generated by tblgen.
135   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
136
137   /// getStackAlignment - Returns the minimum alignment known to hold of the
138   /// stack frame on entry to the function and which must be maintained by every
139   /// function for this subtarget.
140   unsigned getStackAlignment() const { return StackAlignment; }
141
142   /// getDarwinDirective - Returns the -m directive specified for the cpu.
143   ///
144   unsigned getDarwinDirective() const { return DarwinDirective; }
145
146   /// getInstrItins - Return the instruction itineraries based on subtarget
147   /// selection.
148   const InstrItineraryData *getInstrItineraryData() const override {
149     return &InstrItins;
150   }
151
152   const PPCFrameLowering *getFrameLowering() const override {
153     return &FrameLowering;
154   }
155   const DataLayout *getDataLayout() const override { return &DL; }
156   const PPCInstrInfo *getInstrInfo() const override { return &InstrInfo; }
157   const PPCTargetLowering *getTargetLowering() const override {
158     return &TLInfo;
159   }
160   const PPCSelectionDAGInfo *getSelectionDAGInfo() const override {
161     return &TSInfo;
162   }
163   const PPCRegisterInfo *getRegisterInfo() const override {
164     return &getInstrInfo()->getRegisterInfo();
165   }
166
167   /// initializeSubtargetDependencies - Initializes using a CPU and feature string
168   /// so that we can use initializer lists for subtarget initialization.
169   PPCSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
170
171 private:
172   void initializeEnvironment();
173   void initSubtargetFeatures(StringRef CPU, StringRef FS);
174
175 public:
176   /// isPPC64 - Return true if we are generating code for 64-bit pointer mode.
177   ///
178   bool isPPC64() const { return IsPPC64; }
179
180   /// has64BitSupport - Return true if the selected CPU supports 64-bit
181   /// instructions, regardless of whether we are in 32-bit or 64-bit mode.
182   bool has64BitSupport() const { return Has64BitSupport; }
183
184   /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit
185   /// registers in 32-bit mode when possible.  This can only true if
186   /// has64BitSupport() returns true.
187   bool use64BitRegs() const { return Use64BitRegs; }
188
189   /// useCRBits - Return true if we should store and manipulate i1 values in
190   /// the individual condition register bits.
191   bool useCRBits() const { return UseCRBits; }
192
193   /// hasLazyResolverStub - Return true if accesses to the specified global have
194   /// to go through a dyld lazy resolution stub.  This means that an extra load
195   /// is required to get the address of the global.
196   bool hasLazyResolverStub(const GlobalValue *GV,
197                            const TargetMachine &TM) const;
198
199   // isLittleEndian - True if generating little-endian code
200   bool isLittleEndian() const { return IsLittleEndian; }
201
202   // Specific obvious features.
203   bool hasFCPSGN() const { return HasFCPSGN; }
204   bool hasFSQRT() const { return HasFSQRT; }
205   bool hasFRE() const { return HasFRE; }
206   bool hasFRES() const { return HasFRES; }
207   bool hasFRSQRTE() const { return HasFRSQRTE; }
208   bool hasFRSQRTES() const { return HasFRSQRTES; }
209   bool hasRecipPrec() const { return HasRecipPrec; }
210   bool hasSTFIWX() const { return HasSTFIWX; }
211   bool hasLFIWAX() const { return HasLFIWAX; }
212   bool hasFPRND() const { return HasFPRND; }
213   bool hasFPCVT() const { return HasFPCVT; }
214   bool hasAltivec() const { return HasAltivec; }
215   bool hasSPE() const { return HasSPE; }
216   bool hasQPX() const { return HasQPX; }
217   bool hasVSX() const { return HasVSX; }
218   bool hasMFOCRF() const { return HasMFOCRF; }
219   bool hasISEL() const { return HasISEL; }
220   bool hasPOPCNTD() const { return HasPOPCNTD; }
221   bool hasLDBRX() const { return HasLDBRX; }
222   bool isBookE() const { return IsBookE; }
223   bool hasOnlyMSYNC() const { return HasOnlyMSYNC; }
224   bool isPPC4xx() const { return IsPPC4xx; }
225   bool isPPC6xx() const { return IsPPC6xx; }
226   bool isE500() const { return IsE500; }
227   bool isDeprecatedMFTB() const { return DeprecatedMFTB; }
228   bool isDeprecatedDST() const { return DeprecatedDST; }
229
230   const Triple &getTargetTriple() const { return TargetTriple; }
231
232   /// isDarwin - True if this is any darwin platform.
233   bool isDarwin() const { return TargetTriple.isMacOSX(); }
234   /// isBGQ - True if this is a BG/Q platform.
235   bool isBGQ() const { return TargetTriple.getVendor() == Triple::BGQ; }
236
237   bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
238   bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
239
240   bool isDarwinABI() const { return isDarwin(); }
241   bool isSVR4ABI() const { return !isDarwin(); }
242   bool isELFv2ABI() const { return TargetABI == PPC_ABI_ELFv2; }
243
244   bool enableEarlyIfConversion() const override { return hasISEL(); }
245
246   // Scheduling customization.
247   bool enableMachineScheduler() const override;
248   // This overrides the PostRAScheduler bit in the SchedModel for each CPU.
249   bool enablePostMachineScheduler() const override;
250   AntiDepBreakMode getAntiDepBreakMode() const override;
251   void getCriticalPathRCs(RegClassVector &CriticalPathRCs) const override;
252
253   void overrideSchedPolicy(MachineSchedPolicy &Policy,
254                            MachineInstr *begin,
255                            MachineInstr *end,
256                            unsigned NumRegionInstrs) const override;
257   bool useAA() const override;
258 };
259 } // End llvm namespace
260
261 #endif