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 "PPCJITInfo.h"
20 #include "llvm/ADT/Triple.h"
21 #include "llvm/IR/DataLayout.h"
22 #include "llvm/MC/MCInstrItineraries.h"
23 #include "llvm/Target/TargetSubtargetInfo.h"
26 #define GET_SUBTARGETINFO_HEADER
27 #include "PPCGenSubtargetInfo.inc"
29 // GCC #defines PPC on Linux but we use it as our namespace name
36 // -m directive values.
64 class PPCSubtarget : public PPCGenSubtargetInfo {
66 /// stackAlignment - The minimum alignment known to hold of the stack frame on
67 /// entry to the function and which must be maintained by every function.
68 unsigned StackAlignment;
70 /// Selected instruction itineraries (one entry per itinerary class.)
71 InstrItineraryData InstrItins;
73 /// Which cpu directive was used.
74 unsigned DarwinDirective;
76 /// Used by the ISel to turn in optimizations for POWER4-derived architectures
87 bool HasFRE, HasFRES, HasFRSQRTE, HasFRSQRTES;
99 bool HasLazyResolverStubs;
103 /// TargetTriple - What processor and OS we're targeting.
106 /// OptLevel - What default optimization level we're emitting code for.
107 CodeGenOpt::Level OptLevel;
109 PPCFrameLowering FrameLowering;
111 PPCInstrInfo InstrInfo;
115 /// This constructor initializes the data members to match that
116 /// of the specified triple.
118 PPCSubtarget(const std::string &TT, const std::string &CPU,
119 const std::string &FS, bool is64Bit,
120 CodeGenOpt::Level OptLevel);
122 /// ParseSubtargetFeatures - Parses features string setting specified
123 /// subtarget options. Definition of function is auto generated by tblgen.
124 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
126 /// SetJITMode - This is called to inform the subtarget info that we are
127 /// producing code for the JIT.
130 /// getStackAlignment - Returns the minimum alignment known to hold of the
131 /// stack frame on entry to the function and which must be maintained by every
132 /// function for this subtarget.
133 unsigned getStackAlignment() const { return StackAlignment; }
135 /// getDarwinDirective - Returns the -m directive specified for the cpu.
137 unsigned getDarwinDirective() const { return DarwinDirective; }
139 /// getInstrItins - Return the instruction itineraies based on subtarget
141 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
143 const PPCFrameLowering *getFrameLowering() const { return &FrameLowering; }
144 const DataLayout *getDataLayout() const { return &DL; }
145 const PPCInstrInfo *getInstrInfo() const { return &InstrInfo; }
146 PPCJITInfo *getJITInfo() { return &JITInfo; }
148 /// initializeSubtargetDependencies - Initializes using a CPU and feature string
149 /// so that we can use initializer lists for subtarget initialization.
150 PPCSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
152 /// \brief Reset the features for the PowerPC target.
153 void resetSubtargetFeatures(const MachineFunction *MF) override;
155 void initializeEnvironment();
156 void resetSubtargetFeatures(StringRef CPU, StringRef FS);
159 /// isPPC64 - Return true if we are generating code for 64-bit pointer mode.
161 bool isPPC64() const { return IsPPC64; }
163 /// has64BitSupport - Return true if the selected CPU supports 64-bit
164 /// instructions, regardless of whether we are in 32-bit or 64-bit mode.
165 bool has64BitSupport() const { return Has64BitSupport; }
167 /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit
168 /// registers in 32-bit mode when possible. This can only true if
169 /// has64BitSupport() returns true.
170 bool use64BitRegs() const { return Use64BitRegs; }
172 /// useCRBits - Return true if we should store and manipulate i1 values in
173 /// the individual condition register bits.
174 bool useCRBits() const { return UseCRBits; }
176 /// hasLazyResolverStub - Return true if accesses to the specified global have
177 /// to go through a dyld lazy resolution stub. This means that an extra load
178 /// is required to get the address of the global.
179 bool hasLazyResolverStub(const GlobalValue *GV,
180 const TargetMachine &TM) const;
182 // isJITCodeModel - True if we're generating code for the JIT
183 bool isJITCodeModel() const { return IsJITCodeModel; }
185 // isLittleEndian - True if generating little-endian code
186 bool isLittleEndian() const { return IsLittleEndian; }
188 // Specific obvious features.
189 bool hasFCPSGN() const { return HasFCPSGN; }
190 bool hasFSQRT() const { return HasFSQRT; }
191 bool hasFRE() const { return HasFRE; }
192 bool hasFRES() const { return HasFRES; }
193 bool hasFRSQRTE() const { return HasFRSQRTE; }
194 bool hasFRSQRTES() const { return HasFRSQRTES; }
195 bool hasRecipPrec() const { return HasRecipPrec; }
196 bool hasSTFIWX() const { return HasSTFIWX; }
197 bool hasLFIWAX() const { return HasLFIWAX; }
198 bool hasFPRND() const { return HasFPRND; }
199 bool hasFPCVT() const { return HasFPCVT; }
200 bool hasAltivec() const { return HasAltivec; }
201 bool hasQPX() const { return HasQPX; }
202 bool hasVSX() const { return HasVSX; }
203 bool hasMFOCRF() const { return HasMFOCRF; }
204 bool hasISEL() const { return HasISEL; }
205 bool hasPOPCNTD() const { return HasPOPCNTD; }
206 bool hasLDBRX() const { return HasLDBRX; }
207 bool isBookE() const { return IsBookE; }
208 bool isDeprecatedMFTB() const { return DeprecatedMFTB; }
209 bool isDeprecatedDST() const { return DeprecatedDST; }
211 const Triple &getTargetTriple() const { return TargetTriple; }
213 /// isDarwin - True if this is any darwin platform.
214 bool isDarwin() const { return TargetTriple.isMacOSX(); }
215 /// isBGQ - True if this is a BG/Q platform.
216 bool isBGQ() const { return TargetTriple.getVendor() == Triple::BGQ; }
218 bool isDarwinABI() const { return isDarwin(); }
219 bool isSVR4ABI() const { return !isDarwin(); }
221 /// enablePostRAScheduler - True at 'More' optimization.
222 bool enablePostRAScheduler(CodeGenOpt::Level OptLevel,
223 TargetSubtargetInfo::AntiDepBreakMode& Mode,
224 RegClassVector& CriticalPathRCs) const override;
226 bool enableEarlyIfConversion() const override { return hasISEL(); }
228 // Scheduling customization.
229 bool enableMachineScheduler() const override;
230 void overrideSchedPolicy(MachineSchedPolicy &Policy,
233 unsigned NumRegionInstrs) const override;
234 bool useAA() const override;
236 } // End llvm namespace