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 POWERPCSUBTARGET_H 00015 #define POWERPCSUBTARGET_H 00016 00017 #include "llvm/ADT/Triple.h" 00018 #include "llvm/MC/MCInstrItineraries.h" 00019 #include "llvm/Target/TargetSubtargetInfo.h" 00020 #include <string> 00021 00022 #define GET_SUBTARGETINFO_HEADER 00023 #include "PPCGenSubtargetInfo.inc" 00024 00025 // GCC #defines PPC on Linux but we use it as our namespace name 00026 #undef PPC 00027 00028 namespace llvm { 00029 class StringRef; 00030 00031 namespace PPC { 00032 // -m directive values. 00033 enum { 00034 DIR_NONE, 00035 DIR_32, 00036 DIR_440, 00037 DIR_601, 00038 DIR_602, 00039 DIR_603, 00040 DIR_7400, 00041 DIR_750, 00042 DIR_970, 00043 DIR_A2, 00044 DIR_E500mc, 00045 DIR_E5500, 00046 DIR_PWR3, 00047 DIR_PWR4, 00048 DIR_PWR5, 00049 DIR_PWR5X, 00050 DIR_PWR6, 00051 DIR_PWR6X, 00052 DIR_PWR7, 00053 DIR_64 00054 }; 00055 } 00056 00057 class GlobalValue; 00058 class TargetMachine; 00059 00060 class PPCSubtarget : public PPCGenSubtargetInfo { 00061 protected: 00062 /// stackAlignment - The minimum alignment known to hold of the stack frame on 00063 /// entry to the function and which must be maintained by every function. 00064 unsigned StackAlignment; 00065 00066 /// Selected instruction itineraries (one entry per itinerary class.) 00067 InstrItineraryData InstrItins; 00068 00069 /// Which cpu directive was used. 00070 unsigned DarwinDirective; 00071 00072 /// Used by the ISel to turn in optimizations for POWER4-derived architectures 00073 bool HasMFOCRF; 00074 bool Has64BitSupport; 00075 bool Use64BitRegs; 00076 bool IsPPC64; 00077 bool HasAltivec; 00078 bool HasQPX; 00079 bool HasFSQRT; 00080 bool HasFRE, HasFRES, HasFRSQRTE, HasFRSQRTES; 00081 bool HasRecipPrec; 00082 bool HasSTFIWX; 00083 bool HasLFIWAX; 00084 bool HasFPRND; 00085 bool HasFPCVT; 00086 bool HasISEL; 00087 bool HasPOPCNTD; 00088 bool HasLDBRX; 00089 bool IsBookE; 00090 bool HasLazyResolverStubs; 00091 bool IsJITCodeModel; 00092 00093 /// TargetTriple - What processor and OS we're targeting. 00094 Triple TargetTriple; 00095 00096 public: 00097 /// This constructor initializes the data members to match that 00098 /// of the specified triple. 00099 /// 00100 PPCSubtarget(const std::string &TT, const std::string &CPU, 00101 const std::string &FS, bool is64Bit); 00102 00103 /// ParseSubtargetFeatures - Parses features string setting specified 00104 /// subtarget options. Definition of function is auto generated by tblgen. 00105 void ParseSubtargetFeatures(StringRef CPU, StringRef FS); 00106 00107 /// SetJITMode - This is called to inform the subtarget info that we are 00108 /// producing code for the JIT. 00109 void SetJITMode(); 00110 00111 /// getStackAlignment - Returns the minimum alignment known to hold of the 00112 /// stack frame on entry to the function and which must be maintained by every 00113 /// function for this subtarget. 00114 unsigned getStackAlignment() const { return StackAlignment; } 00115 00116 /// getDarwinDirective - Returns the -m directive specified for the cpu. 00117 /// 00118 unsigned getDarwinDirective() const { return DarwinDirective; } 00119 00120 /// getInstrItins - Return the instruction itineraies based on subtarget 00121 /// selection. 00122 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; } 00123 00124 /// getDataLayoutString - Return the pointer size and type alignment 00125 /// properties of this subtarget. 00126 const char *getDataLayoutString() const { 00127 // Note, the alignment values for f64 and i64 on ppc64 in Darwin 00128 // documentation are wrong; these are correct (i.e. "what gcc does"). 00129 if (isPPC64() && isSVR4ABI()) { 00130 if (TargetTriple.getOS() == llvm::Triple::FreeBSD) 00131 return "E-p:64:64-f64:64:64-i64:64:64-f128:64:64-v128:128:128-n32:64"; 00132 else 00133 return "E-p:64:64-f64:64:64-i64:64:64-f128:128:128-v128:128:128-n32:64"; 00134 } 00135 00136 return isPPC64() ? "E-p:64:64-f64:64:64-i64:64:64-f128:64:128-n32:64" 00137 : "E-p:32:32-f64:64:64-i64:64:64-f128:64:128-n32"; 00138 } 00139 00140 /// isPPC64 - Return true if we are generating code for 64-bit pointer mode. 00141 /// 00142 bool isPPC64() const { return IsPPC64; } 00143 00144 /// has64BitSupport - Return true if the selected CPU supports 64-bit 00145 /// instructions, regardless of whether we are in 32-bit or 64-bit mode. 00146 bool has64BitSupport() const { return Has64BitSupport; } 00147 00148 /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit 00149 /// registers in 32-bit mode when possible. This can only true if 00150 /// has64BitSupport() returns true. 00151 bool use64BitRegs() const { return Use64BitRegs; } 00152 00153 /// hasLazyResolverStub - Return true if accesses to the specified global have 00154 /// to go through a dyld lazy resolution stub. This means that an extra load 00155 /// is required to get the address of the global. 00156 bool hasLazyResolverStub(const GlobalValue *GV, 00157 const TargetMachine &TM) const; 00158 00159 // isJITCodeModel - True if we're generating code for the JIT 00160 bool isJITCodeModel() const { return IsJITCodeModel; } 00161 00162 // Specific obvious features. 00163 bool hasFSQRT() const { return HasFSQRT; } 00164 bool hasFRE() const { return HasFRE; } 00165 bool hasFRES() const { return HasFRES; } 00166 bool hasFRSQRTE() const { return HasFRSQRTE; } 00167 bool hasFRSQRTES() const { return HasFRSQRTES; } 00168 bool hasRecipPrec() const { return HasRecipPrec; } 00169 bool hasSTFIWX() const { return HasSTFIWX; } 00170 bool hasLFIWAX() const { return HasLFIWAX; } 00171 bool hasFPRND() const { return HasFPRND; } 00172 bool hasFPCVT() const { return HasFPCVT; } 00173 bool hasAltivec() const { return HasAltivec; } 00174 bool hasQPX() const { return HasQPX; } 00175 bool hasMFOCRF() const { return HasMFOCRF; } 00176 bool hasISEL() const { return HasISEL; } 00177 bool hasPOPCNTD() const { return HasPOPCNTD; } 00178 bool hasLDBRX() const { return HasLDBRX; } 00179 bool isBookE() const { return IsBookE; } 00180 00181 const Triple &getTargetTriple() const { return TargetTriple; } 00182 00183 /// isDarwin - True if this is any darwin platform. 00184 bool isDarwin() const { return TargetTriple.isMacOSX(); } 00185 /// isBGP - True if this is a BG/P platform. 00186 bool isBGP() const { return TargetTriple.getVendor() == Triple::BGP; } 00187 /// isBGQ - True if this is a BG/Q platform. 00188 bool isBGQ() const { return TargetTriple.getVendor() == Triple::BGQ; } 00189 00190 bool isDarwinABI() const { return isDarwin(); } 00191 bool isSVR4ABI() const { return !isDarwin(); } 00192 00193 /// enablePostRAScheduler - True at 'More' optimization. 00194 bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, 00195 TargetSubtargetInfo::AntiDepBreakMode& Mode, 00196 RegClassVector& CriticalPathRCs) const; 00197 }; 00198 } // End llvm namespace 00199 00200 #endif