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 POWERPCSUBTARGET_H
15 #define POWERPCSUBTARGET_H
17 #include "PPCFrameLowering.h"
18 #include "PPCInstrInfo.h"
19 #include "PPCISelLowering.h"
20 #include "PPCJITInfo.h"
21 #include "PPCSelectionDAGInfo.h"
22 #include "llvm/ADT/Triple.h"
23 #include "llvm/IR/DataLayout.h"
24 #include "llvm/MC/MCInstrItineraries.h"
25 #include "llvm/Target/TargetSubtargetInfo.h"
28 #define GET_SUBTARGETINFO_HEADER
29 #include "PPCGenSubtargetInfo.inc"
31 // GCC #defines PPC on Linux but we use it as our namespace name
38 // -m directive values.
67 class PPCSubtarget : public PPCGenSubtargetInfo {
69 /// stackAlignment - The minimum alignment known to hold of the stack frame on
70 /// entry to the function and which must be maintained by every function.
71 unsigned StackAlignment;
73 /// Selected instruction itineraries (one entry per itinerary class.)
74 InstrItineraryData InstrItins;
76 /// Which cpu directive was used.
77 unsigned DarwinDirective;
79 /// Used by the ISel to turn in optimizations for POWER4-derived architectures
91 bool HasFRE, HasFRES, HasFRSQRTE, HasFRSQRTES;
106 bool HasLazyResolverStubs;
110 /// TargetTriple - What processor and OS we're targeting.
113 /// OptLevel - What default optimization level we're emitting code for.
114 CodeGenOpt::Level OptLevel;
122 PPCFrameLowering FrameLowering;
124 PPCInstrInfo InstrInfo;
126 PPCTargetLowering TLInfo;
127 PPCSelectionDAGInfo TSInfo;
130 /// This constructor initializes the data members to match that
131 /// of the specified triple.
133 PPCSubtarget(const std::string &TT, const std::string &CPU,
134 const std::string &FS, PPCTargetMachine &TM, bool is64Bit,
135 CodeGenOpt::Level OptLevel);
137 /// ParseSubtargetFeatures - Parses features string setting specified
138 /// subtarget options. Definition of function is auto generated by tblgen.
139 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
141 /// SetJITMode - This is called to inform the subtarget info that we are
142 /// producing code for the JIT.
145 /// getStackAlignment - Returns the minimum alignment known to hold of the
146 /// stack frame on entry to the function and which must be maintained by every
147 /// function for this subtarget.
148 unsigned getStackAlignment() const { return StackAlignment; }
150 /// getDarwinDirective - Returns the -m directive specified for the cpu.
152 unsigned getDarwinDirective() const { return DarwinDirective; }
154 /// getInstrItins - Return the instruction itineraries based on subtarget
156 const InstrItineraryData *getInstrItineraryData() const override {
160 const PPCFrameLowering *getFrameLowering() const override {
161 return &FrameLowering;
163 const DataLayout *getDataLayout() const override { return &DL; }
164 const PPCInstrInfo *getInstrInfo() const override { return &InstrInfo; }
165 PPCJITInfo *getJITInfo() override { return &JITInfo; }
166 const PPCTargetLowering *getTargetLowering() const override {
169 const PPCSelectionDAGInfo *getSelectionDAGInfo() const override {
172 const PPCRegisterInfo *getRegisterInfo() const override {
173 return &getInstrInfo()->getRegisterInfo();
176 /// initializeSubtargetDependencies - Initializes using a CPU and feature string
177 /// so that we can use initializer lists for subtarget initialization.
178 PPCSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
180 /// \brief Reset the features for the PowerPC target.
181 void resetSubtargetFeatures(const MachineFunction *MF) override;
183 void initializeEnvironment();
184 void resetSubtargetFeatures(StringRef CPU, StringRef FS);
187 /// isPPC64 - Return true if we are generating code for 64-bit pointer mode.
189 bool isPPC64() const { return IsPPC64; }
191 /// has64BitSupport - Return true if the selected CPU supports 64-bit
192 /// instructions, regardless of whether we are in 32-bit or 64-bit mode.
193 bool has64BitSupport() const { return Has64BitSupport; }
195 /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit
196 /// registers in 32-bit mode when possible. This can only true if
197 /// has64BitSupport() returns true.
198 bool use64BitRegs() const { return Use64BitRegs; }
200 /// useCRBits - Return true if we should store and manipulate i1 values in
201 /// the individual condition register bits.
202 bool useCRBits() const { return UseCRBits; }
204 /// hasLazyResolverStub - Return true if accesses to the specified global have
205 /// to go through a dyld lazy resolution stub. This means that an extra load
206 /// is required to get the address of the global.
207 bool hasLazyResolverStub(const GlobalValue *GV,
208 const TargetMachine &TM) const;
210 // isJITCodeModel - True if we're generating code for the JIT
211 bool isJITCodeModel() const { return IsJITCodeModel; }
213 // isLittleEndian - True if generating little-endian code
214 bool isLittleEndian() const { return IsLittleEndian; }
216 // Specific obvious features.
217 bool hasFCPSGN() const { return HasFCPSGN; }
218 bool hasFSQRT() const { return HasFSQRT; }
219 bool hasFRE() const { return HasFRE; }
220 bool hasFRES() const { return HasFRES; }
221 bool hasFRSQRTE() const { return HasFRSQRTE; }
222 bool hasFRSQRTES() const { return HasFRSQRTES; }
223 bool hasRecipPrec() const { return HasRecipPrec; }
224 bool hasSTFIWX() const { return HasSTFIWX; }
225 bool hasLFIWAX() const { return HasLFIWAX; }
226 bool hasFPRND() const { return HasFPRND; }
227 bool hasFPCVT() const { return HasFPCVT; }
228 bool hasAltivec() const { return HasAltivec; }
229 bool hasSPE() const { return HasSPE; }
230 bool hasQPX() const { return HasQPX; }
231 bool hasVSX() const { return HasVSX; }
232 bool hasMFOCRF() const { return HasMFOCRF; }
233 bool hasISEL() const { return HasISEL; }
234 bool hasPOPCNTD() const { return HasPOPCNTD; }
235 bool hasLDBRX() const { return HasLDBRX; }
236 bool isBookE() const { return IsBookE; }
237 bool isPPC4xx() const { return IsPPC4xx; }
238 bool isPPC6xx() const { return IsPPC6xx; }
239 bool isE500() const { return IsE500; }
240 bool isDeprecatedMFTB() const { return DeprecatedMFTB; }
241 bool isDeprecatedDST() const { return DeprecatedDST; }
243 const Triple &getTargetTriple() const { return TargetTriple; }
245 /// isDarwin - True if this is any darwin platform.
246 bool isDarwin() const { return TargetTriple.isMacOSX(); }
247 /// isBGQ - True if this is a BG/Q platform.
248 bool isBGQ() const { return TargetTriple.getVendor() == Triple::BGQ; }
250 bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
251 bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
253 bool isDarwinABI() const { return isDarwin(); }
254 bool isSVR4ABI() const { return !isDarwin(); }
255 bool isELFv2ABI() const { return TargetABI == PPC_ABI_ELFv2; }
257 bool enableEarlyIfConversion() const override { return hasISEL(); }
259 // Scheduling customization.
260 bool enableMachineScheduler() const override;
261 // This overrides the PostRAScheduler bit in the SchedModel for each CPU.
262 bool enablePostMachineScheduler() const override;
263 AntiDepBreakMode getAntiDepBreakMode() const override;
264 void getCriticalPathRCs(RegClassVector &CriticalPathRCs) const override;
266 void overrideSchedPolicy(MachineSchedPolicy &Policy,
269 unsigned NumRegionInstrs) const override;
270 bool useAA() const override;
272 } // End llvm namespace