1 //===-- PPCSubtarget.h - Define Subtarget for the PPC ----------*- C++ -*--===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the PowerPC specific subclass of TargetSubtargetInfo.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_POWERPC_PPCSUBTARGET_H
15 #define LLVM_LIB_TARGET_POWERPC_PPCSUBTARGET_H
17 #include "PPCFrameLowering.h"
18 #include "PPCISelLowering.h"
19 #include "PPCInstrInfo.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"
27 #define GET_SUBTARGETINFO_HEADER
28 #include "PPCGenSubtargetInfo.inc"
30 // GCC #defines PPC on Linux but we use it as our namespace name
37 // -m directive values.
66 class PPCSubtarget : public PPCGenSubtargetInfo {
68 /// TargetTriple - What processor and OS we're targeting.
71 /// stackAlignment - The minimum alignment known to hold of the stack frame on
72 /// entry to the function and which must be maintained by every function.
73 unsigned StackAlignment;
75 /// Selected instruction itineraries (one entry per itinerary class.)
76 InstrItineraryData InstrItins;
78 /// Which cpu directive was used.
79 unsigned DarwinDirective;
81 /// Used by the ISel to turn in optimizations for POWER4-derived architectures
96 bool HasFRE, HasFRES, HasFRSQRTE, HasFRSQRTES;
115 bool HasLazyResolverStubs;
118 bool HasInvariantFunctionDescriptors;
119 bool HasPartwordAtomics;
122 /// When targeting QPX running a stock PPC64 Linux kernel where the stack
123 /// alignment has not been changed, we need to keep the 16-byte alignment
125 bool IsQPXStackUnaligned;
127 const PPCTargetMachine &TM;
128 PPCFrameLowering FrameLowering;
129 PPCInstrInfo InstrInfo;
130 PPCTargetLowering TLInfo;
131 PPCSelectionDAGInfo TSInfo;
134 /// This constructor initializes the data members to match that
135 /// of the specified triple.
137 PPCSubtarget(const std::string &TT, const std::string &CPU,
138 const std::string &FS, const PPCTargetMachine &TM);
140 /// ParseSubtargetFeatures - Parses features string setting specified
141 /// subtarget options. Definition of function is auto generated by tblgen.
142 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
144 /// getStackAlignment - Returns the minimum alignment known to hold of the
145 /// stack frame on entry to the function and which must be maintained by every
146 /// function for this subtarget.
147 unsigned getStackAlignment() const { return StackAlignment; }
149 /// getDarwinDirective - Returns the -m directive specified for the cpu.
151 unsigned getDarwinDirective() const { return DarwinDirective; }
153 /// getInstrItins - Return the instruction itineraries based on subtarget
155 const InstrItineraryData *getInstrItineraryData() const override {
159 const PPCFrameLowering *getFrameLowering() const override {
160 return &FrameLowering;
162 const PPCInstrInfo *getInstrInfo() const override { return &InstrInfo; }
163 const PPCTargetLowering *getTargetLowering() const override {
166 const PPCSelectionDAGInfo *getSelectionDAGInfo() const override {
169 const PPCRegisterInfo *getRegisterInfo() const override {
170 return &getInstrInfo()->getRegisterInfo();
172 const PPCTargetMachine &getTargetMachine() const { return TM; }
174 /// initializeSubtargetDependencies - Initializes using a CPU and feature string
175 /// so that we can use initializer lists for subtarget initialization.
176 PPCSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
179 void initializeEnvironment();
180 void initSubtargetFeatures(StringRef CPU, StringRef FS);
183 /// isPPC64 - Return true if we are generating code for 64-bit pointer mode.
185 bool isPPC64() const;
187 /// has64BitSupport - Return true if the selected CPU supports 64-bit
188 /// instructions, regardless of whether we are in 32-bit or 64-bit mode.
189 bool has64BitSupport() const { return Has64BitSupport; }
191 /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit
192 /// registers in 32-bit mode when possible. This can only true if
193 /// has64BitSupport() returns true.
194 bool use64BitRegs() const { return Use64BitRegs; }
196 /// useCRBits - Return true if we should store and manipulate i1 values in
197 /// the individual condition register bits.
198 bool useCRBits() const { return UseCRBits; }
200 /// hasLazyResolverStub - Return true if accesses to the specified global have
201 /// to go through a dyld lazy resolution stub. This means that an extra load
202 /// is required to get the address of the global.
203 bool hasLazyResolverStub(const GlobalValue *GV) const;
205 // isLittleEndian - True if generating little-endian code
206 bool isLittleEndian() const { return IsLittleEndian; }
208 // Specific obvious features.
209 bool hasFCPSGN() const { return HasFCPSGN; }
210 bool hasFSQRT() const { return HasFSQRT; }
211 bool hasFRE() const { return HasFRE; }
212 bool hasFRES() const { return HasFRES; }
213 bool hasFRSQRTE() const { return HasFRSQRTE; }
214 bool hasFRSQRTES() const { return HasFRSQRTES; }
215 bool hasRecipPrec() const { return HasRecipPrec; }
216 bool hasSTFIWX() const { return HasSTFIWX; }
217 bool hasLFIWAX() const { return HasLFIWAX; }
218 bool hasFPRND() const { return HasFPRND; }
219 bool hasFPCVT() const { return HasFPCVT; }
220 bool hasAltivec() const { return HasAltivec; }
221 bool hasSPE() const { return HasSPE; }
222 bool hasQPX() const { return HasQPX; }
223 bool hasVSX() const { return HasVSX; }
224 bool hasP8Vector() const { return HasP8Vector; }
225 bool hasP8Altivec() const { return HasP8Altivec; }
226 bool hasP8Crypto() const { return HasP8Crypto; }
227 bool hasMFOCRF() const { return HasMFOCRF; }
228 bool hasISEL() const { return HasISEL; }
229 bool hasPOPCNTD() const { return HasPOPCNTD; }
230 bool hasBPERMD() const { return HasBPERMD; }
231 bool hasExtDiv() const { return HasExtDiv; }
232 bool hasCMPB() const { return HasCMPB; }
233 bool hasLDBRX() const { return HasLDBRX; }
234 bool isBookE() const { return IsBookE; }
235 bool hasOnlyMSYNC() const { return HasOnlyMSYNC; }
236 bool isPPC4xx() const { return IsPPC4xx; }
237 bool isPPC6xx() const { return IsPPC6xx; }
238 bool isE500() const { return IsE500; }
239 bool isDeprecatedMFTB() const { return DeprecatedMFTB; }
240 bool isDeprecatedDST() const { return DeprecatedDST; }
241 bool hasICBT() const { return HasICBT; }
242 bool hasInvariantFunctionDescriptors() const {
243 return HasInvariantFunctionDescriptors;
245 bool hasPartwordAtomics() const { return HasPartwordAtomics; }
247 bool isQPXStackUnaligned() const { return IsQPXStackUnaligned; }
248 unsigned getPlatformStackAlignment() const {
249 if ((hasQPX() || isBGQ()) && !isQPXStackUnaligned())
254 bool hasHTM() const { return HasHTM; }
256 const Triple &getTargetTriple() const { return TargetTriple; }
258 /// isDarwin - True if this is any darwin platform.
259 bool isDarwin() const { return TargetTriple.isMacOSX(); }
260 /// isBGQ - True if this is a BG/Q platform.
261 bool isBGQ() const { return TargetTriple.getVendor() == Triple::BGQ; }
263 bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
264 bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
266 bool isDarwinABI() const { return isTargetMachO() || isDarwin(); }
267 bool isSVR4ABI() const { return !isDarwinABI(); }
268 bool isELFv2ABI() const;
270 bool enableEarlyIfConversion() const override { return hasISEL(); }
272 // Scheduling customization.
273 bool enableMachineScheduler() const override;
274 // This overrides the PostRAScheduler bit in the SchedModel for each CPU.
275 bool enablePostMachineScheduler() const override;
276 AntiDepBreakMode getAntiDepBreakMode() const override;
277 void getCriticalPathRCs(RegClassVector &CriticalPathRCs) const override;
279 void overrideSchedPolicy(MachineSchedPolicy &Policy,
282 unsigned NumRegionInstrs) const override;
283 bool useAA() const override;
285 bool enableSubRegLiveness() const override;
287 } // End llvm namespace