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 TargetSubtarget. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef POWERPCSUBTARGET_H 00015 #define POWERPCSUBTARGET_H 00016 00017 #include "llvm/Target/TargetInstrItineraries.h" 00018 #include "llvm/Target/TargetSubtarget.h" 00019 00020 #include <string> 00021 00022 // GCC #defines PPC on Linux but we use it as our namespace name 00023 #undef PPC 00024 00025 namespace llvm { 00026 00027 namespace PPC { 00028 // -m directive values. 00029 enum { 00030 DIR_NONE, 00031 DIR_32, 00032 DIR_601, 00033 DIR_602, 00034 DIR_603, 00035 DIR_7400, 00036 DIR_750, 00037 DIR_970, 00038 DIR_64 00039 }; 00040 } 00041 00042 class GlobalValue; 00043 class TargetMachine; 00044 00045 class PPCSubtarget : public TargetSubtarget { 00046 protected: 00047 /// stackAlignment - The minimum alignment known to hold of the stack frame on 00048 /// entry to the function and which must be maintained by every function. 00049 unsigned StackAlignment; 00050 00051 /// Selected instruction itineraries (one entry per itinerary class.) 00052 InstrItineraryData InstrItins; 00053 00054 /// Which cpu directive was used. 00055 unsigned DarwinDirective; 00056 00057 /// Used by the ISel to turn in optimizations for POWER4-derived architectures 00058 bool IsGigaProcessor; 00059 bool Has64BitSupport; 00060 bool Use64BitRegs; 00061 bool IsPPC64; 00062 bool HasAltivec; 00063 bool HasFSQRT; 00064 bool HasSTFIWX; 00065 bool HasLazyResolverStubs; 00066 00067 /// DarwinVers - Nonzero if this is a darwin platform. Otherwise, the numeric 00068 /// version of the platform, e.g. 8 = 10.4 (Tiger), 9 = 10.5 (Leopard), etc. 00069 unsigned char DarwinVers; // Is any darwin-ppc platform. 00070 public: 00071 /// This constructor initializes the data members to match that 00072 /// of the specified triple. 00073 /// 00074 PPCSubtarget(const std::string &TT, const std::string &FS, bool is64Bit); 00075 00076 /// ParseSubtargetFeatures - Parses features string setting specified 00077 /// subtarget options. Definition of function is auto generated by tblgen. 00078 std::string ParseSubtargetFeatures(const std::string &FS, 00079 const std::string &CPU); 00080 00081 00082 /// SetJITMode - This is called to inform the subtarget info that we are 00083 /// producing code for the JIT. 00084 void SetJITMode(); 00085 00086 /// getStackAlignment - Returns the minimum alignment known to hold of the 00087 /// stack frame on entry to the function and which must be maintained by every 00088 /// function for this subtarget. 00089 unsigned getStackAlignment() const { return StackAlignment; } 00090 00091 /// getDarwinDirective - Returns the -m directive specified for the cpu. 00092 /// 00093 unsigned getDarwinDirective() const { return DarwinDirective; } 00094 00095 /// getInstrItins - Return the instruction itineraies based on subtarget 00096 /// selection. 00097 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; } 00098 00099 /// getTargetDataString - Return the pointer size and type alignment 00100 /// properties of this subtarget. 00101 const char *getTargetDataString() const { 00102 // Note, the alignment values for f64 and i64 on ppc64 in Darwin 00103 // documentation are wrong; these are correct (i.e. "what gcc does"). 00104 return isPPC64() ? "E-p:64:64-f64:64:64-i64:64:64-f128:64:128" 00105 : "E-p:32:32-f64:32:64-i64:32:64-f128:64:128"; 00106 } 00107 00108 /// isPPC64 - Return true if we are generating code for 64-bit pointer mode. 00109 /// 00110 bool isPPC64() const { return IsPPC64; } 00111 00112 /// has64BitSupport - Return true if the selected CPU supports 64-bit 00113 /// instructions, regardless of whether we are in 32-bit or 64-bit mode. 00114 bool has64BitSupport() const { return Has64BitSupport; } 00115 00116 /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit 00117 /// registers in 32-bit mode when possible. This can only true if 00118 /// has64BitSupport() returns true. 00119 bool use64BitRegs() const { return Use64BitRegs; } 00120 00121 /// hasLazyResolverStub - Return true if accesses to the specified global have 00122 /// to go through a dyld lazy resolution stub. This means that an extra load 00123 /// is required to get the address of the global. 00124 bool hasLazyResolverStub(const GlobalValue *GV, 00125 const TargetMachine &TM) const; 00126 00127 // Specific obvious features. 00128 bool hasFSQRT() const { return HasFSQRT; } 00129 bool hasSTFIWX() const { return HasSTFIWX; } 00130 bool hasAltivec() const { return HasAltivec; } 00131 bool isGigaProcessor() const { return IsGigaProcessor; } 00132 00133 /// isDarwin - True if this is any darwin platform. 00134 bool isDarwin() const { return DarwinVers != 0; } 00135 /// isDarwin - True if this is darwin9 (leopard, 10.5) or above. 00136 bool isDarwin9() const { return DarwinVers >= 9; } 00137 00138 /// getDarwinVers - Return the darwin version number, 8 = tiger, 9 = leopard. 00139 unsigned getDarwinVers() const { return DarwinVers; } 00140 00141 bool isDarwinABI() const { return isDarwin(); } 00142 bool isSVR4ABI() const { return !isDarwin(); } 00143 00144 }; 00145 } // End llvm namespace 00146 00147 #endif