LLVM API Documentation
00001 //===-- PPCSubtarget.h - Define Subtarget for the PPC ----------*- C++ -*--===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file declares the PowerPC specific subclass of TargetSubtargetInfo. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_LIB_TARGET_POWERPC_PPCSUBTARGET_H 00015 #define LLVM_LIB_TARGET_POWERPC_PPCSUBTARGET_H 00016 00017 #include "PPCFrameLowering.h" 00018 #include "PPCInstrInfo.h" 00019 #include "PPCISelLowering.h" 00020 #include "PPCSelectionDAGInfo.h" 00021 #include "llvm/ADT/Triple.h" 00022 #include "llvm/IR/DataLayout.h" 00023 #include "llvm/MC/MCInstrItineraries.h" 00024 #include "llvm/Target/TargetSubtargetInfo.h" 00025 #include <string> 00026 00027 #define GET_SUBTARGETINFO_HEADER 00028 #include "PPCGenSubtargetInfo.inc" 00029 00030 // GCC #defines PPC on Linux but we use it as our namespace name 00031 #undef PPC 00032 00033 namespace llvm { 00034 class StringRef; 00035 00036 namespace PPC { 00037 // -m directive values. 00038 enum { 00039 DIR_NONE, 00040 DIR_32, 00041 DIR_440, 00042 DIR_601, 00043 DIR_602, 00044 DIR_603, 00045 DIR_7400, 00046 DIR_750, 00047 DIR_970, 00048 DIR_A2, 00049 DIR_E500mc, 00050 DIR_E5500, 00051 DIR_PWR3, 00052 DIR_PWR4, 00053 DIR_PWR5, 00054 DIR_PWR5X, 00055 DIR_PWR6, 00056 DIR_PWR6X, 00057 DIR_PWR7, 00058 DIR_PWR8, 00059 DIR_64 00060 }; 00061 } 00062 00063 class GlobalValue; 00064 class TargetMachine; 00065 00066 class PPCSubtarget : public PPCGenSubtargetInfo { 00067 protected: 00068 /// TargetTriple - What processor and OS we're targeting. 00069 Triple TargetTriple; 00070 00071 // Calculates type size & alignment 00072 const DataLayout DL; 00073 00074 /// stackAlignment - The minimum alignment known to hold of the stack frame on 00075 /// entry to the function and which must be maintained by every function. 00076 unsigned StackAlignment; 00077 00078 /// Selected instruction itineraries (one entry per itinerary class.) 00079 InstrItineraryData InstrItins; 00080 00081 /// Which cpu directive was used. 00082 unsigned DarwinDirective; 00083 00084 /// Used by the ISel to turn in optimizations for POWER4-derived architectures 00085 bool HasMFOCRF; 00086 bool Has64BitSupport; 00087 bool Use64BitRegs; 00088 bool UseCRBits; 00089 bool IsPPC64; 00090 bool HasAltivec; 00091 bool HasSPE; 00092 bool HasQPX; 00093 bool HasVSX; 00094 bool HasFCPSGN; 00095 bool HasFSQRT; 00096 bool HasFRE, HasFRES, HasFRSQRTE, HasFRSQRTES; 00097 bool HasRecipPrec; 00098 bool HasSTFIWX; 00099 bool HasLFIWAX; 00100 bool HasFPRND; 00101 bool HasFPCVT; 00102 bool HasISEL; 00103 bool HasPOPCNTD; 00104 bool HasLDBRX; 00105 bool IsBookE; 00106 bool IsE500; 00107 bool IsPPC4xx; 00108 bool IsPPC6xx; 00109 bool DeprecatedMFTB; 00110 bool DeprecatedDST; 00111 bool HasLazyResolverStubs; 00112 bool IsLittleEndian; 00113 00114 /// OptLevel - What default optimization level we're emitting code for. 00115 CodeGenOpt::Level OptLevel; 00116 00117 enum { 00118 PPC_ABI_UNKNOWN, 00119 PPC_ABI_ELFv1, 00120 PPC_ABI_ELFv2 00121 } TargetABI; 00122 00123 PPCFrameLowering FrameLowering; 00124 PPCInstrInfo InstrInfo; 00125 PPCTargetLowering TLInfo; 00126 PPCSelectionDAGInfo TSInfo; 00127 00128 public: 00129 /// This constructor initializes the data members to match that 00130 /// of the specified triple. 00131 /// 00132 PPCSubtarget(const std::string &TT, const std::string &CPU, 00133 const std::string &FS, PPCTargetMachine &TM, 00134 CodeGenOpt::Level OptLevel); 00135 00136 /// ParseSubtargetFeatures - Parses features string setting specified 00137 /// subtarget options. Definition of function is auto generated by tblgen. 00138 void ParseSubtargetFeatures(StringRef CPU, StringRef FS); 00139 00140 /// getStackAlignment - Returns the minimum alignment known to hold of the 00141 /// stack frame on entry to the function and which must be maintained by every 00142 /// function for this subtarget. 00143 unsigned getStackAlignment() const { return StackAlignment; } 00144 00145 /// getDarwinDirective - Returns the -m directive specified for the cpu. 00146 /// 00147 unsigned getDarwinDirective() const { return DarwinDirective; } 00148 00149 /// getInstrItins - Return the instruction itineraries based on subtarget 00150 /// selection. 00151 const InstrItineraryData *getInstrItineraryData() const override { 00152 return &InstrItins; 00153 } 00154 00155 const PPCFrameLowering *getFrameLowering() const override { 00156 return &FrameLowering; 00157 } 00158 const DataLayout *getDataLayout() const override { return &DL; } 00159 const PPCInstrInfo *getInstrInfo() const override { return &InstrInfo; } 00160 const PPCTargetLowering *getTargetLowering() const override { 00161 return &TLInfo; 00162 } 00163 const PPCSelectionDAGInfo *getSelectionDAGInfo() const override { 00164 return &TSInfo; 00165 } 00166 const PPCRegisterInfo *getRegisterInfo() const override { 00167 return &getInstrInfo()->getRegisterInfo(); 00168 } 00169 00170 /// initializeSubtargetDependencies - Initializes using a CPU and feature string 00171 /// so that we can use initializer lists for subtarget initialization. 00172 PPCSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS); 00173 00174 private: 00175 void initializeEnvironment(); 00176 void initSubtargetFeatures(StringRef CPU, StringRef FS); 00177 00178 public: 00179 /// isPPC64 - Return true if we are generating code for 64-bit pointer mode. 00180 /// 00181 bool isPPC64() const { return IsPPC64; } 00182 00183 /// has64BitSupport - Return true if the selected CPU supports 64-bit 00184 /// instructions, regardless of whether we are in 32-bit or 64-bit mode. 00185 bool has64BitSupport() const { return Has64BitSupport; } 00186 00187 /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit 00188 /// registers in 32-bit mode when possible. This can only true if 00189 /// has64BitSupport() returns true. 00190 bool use64BitRegs() const { return Use64BitRegs; } 00191 00192 /// useCRBits - Return true if we should store and manipulate i1 values in 00193 /// the individual condition register bits. 00194 bool useCRBits() const { return UseCRBits; } 00195 00196 /// hasLazyResolverStub - Return true if accesses to the specified global have 00197 /// to go through a dyld lazy resolution stub. This means that an extra load 00198 /// is required to get the address of the global. 00199 bool hasLazyResolverStub(const GlobalValue *GV, 00200 const TargetMachine &TM) const; 00201 00202 // isLittleEndian - True if generating little-endian code 00203 bool isLittleEndian() const { return IsLittleEndian; } 00204 00205 // Specific obvious features. 00206 bool hasFCPSGN() const { return HasFCPSGN; } 00207 bool hasFSQRT() const { return HasFSQRT; } 00208 bool hasFRE() const { return HasFRE; } 00209 bool hasFRES() const { return HasFRES; } 00210 bool hasFRSQRTE() const { return HasFRSQRTE; } 00211 bool hasFRSQRTES() const { return HasFRSQRTES; } 00212 bool hasRecipPrec() const { return HasRecipPrec; } 00213 bool hasSTFIWX() const { return HasSTFIWX; } 00214 bool hasLFIWAX() const { return HasLFIWAX; } 00215 bool hasFPRND() const { return HasFPRND; } 00216 bool hasFPCVT() const { return HasFPCVT; } 00217 bool hasAltivec() const { return HasAltivec; } 00218 bool hasSPE() const { return HasSPE; } 00219 bool hasQPX() const { return HasQPX; } 00220 bool hasVSX() const { return HasVSX; } 00221 bool hasMFOCRF() const { return HasMFOCRF; } 00222 bool hasISEL() const { return HasISEL; } 00223 bool hasPOPCNTD() const { return HasPOPCNTD; } 00224 bool hasLDBRX() const { return HasLDBRX; } 00225 bool isBookE() const { return IsBookE; } 00226 bool isPPC4xx() const { return IsPPC4xx; } 00227 bool isPPC6xx() const { return IsPPC6xx; } 00228 bool isE500() const { return IsE500; } 00229 bool isDeprecatedMFTB() const { return DeprecatedMFTB; } 00230 bool isDeprecatedDST() const { return DeprecatedDST; } 00231 00232 const Triple &getTargetTriple() const { return TargetTriple; } 00233 00234 /// isDarwin - True if this is any darwin platform. 00235 bool isDarwin() const { return TargetTriple.isMacOSX(); } 00236 /// isBGQ - True if this is a BG/Q platform. 00237 bool isBGQ() const { return TargetTriple.getVendor() == Triple::BGQ; } 00238 00239 bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); } 00240 bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); } 00241 00242 bool isDarwinABI() const { return isDarwin(); } 00243 bool isSVR4ABI() const { return !isDarwin(); } 00244 bool isELFv2ABI() const { return TargetABI == PPC_ABI_ELFv2; } 00245 00246 bool enableEarlyIfConversion() const override { return hasISEL(); } 00247 00248 // Scheduling customization. 00249 bool enableMachineScheduler() const override; 00250 // This overrides the PostRAScheduler bit in the SchedModel for each CPU. 00251 bool enablePostMachineScheduler() const override; 00252 AntiDepBreakMode getAntiDepBreakMode() const override; 00253 void getCriticalPathRCs(RegClassVector &CriticalPathRCs) const override; 00254 00255 void overrideSchedPolicy(MachineSchedPolicy &Policy, 00256 MachineInstr *begin, 00257 MachineInstr *end, 00258 unsigned NumRegionInstrs) const override; 00259 bool useAA() const override; 00260 }; 00261 } // End llvm namespace 00262 00263 #endif