1 //=====-- PPCSubtarget.h - Define Subtarget for the PPC -------*- C++ -*--====// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file declares the PowerPC specific subclass of TargetSubtarget. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef POWERPCSUBTARGET_H 15 #define POWERPCSUBTARGET_H 16 17 #include "llvm/Target/TargetInstrItineraries.h" 18 #include "llvm/Target/TargetSubtarget.h" 19 20 #include <string> 21 22 // GCC #defines PPC on Linux but we use it as our namespace name 23 #undef PPC 24 25 namespace llvm { 26 27 namespace PPC { 28 // -m directive values. 29 enum { 30 DIR_NONE, 31 DIR_32, 32 DIR_601, 33 DIR_602, 34 DIR_603, 35 DIR_7400, 36 DIR_750, 37 DIR_970, 38 DIR_64 39 }; 40 } 41 42 class GlobalValue; 43 class TargetMachine; 44 45 class PPCSubtarget : public TargetSubtarget { 46 protected: 47 /// stackAlignment - The minimum alignment known to hold of the stack frame on 48 /// entry to the function and which must be maintained by every function. 49 unsigned StackAlignment; 50 51 /// Selected instruction itineraries (one entry per itinerary class.) 52 InstrItineraryData InstrItins; 53 54 /// Which cpu directive was used. 55 unsigned DarwinDirective; 56 57 /// Used by the ISel to turn in optimizations for POWER4-derived architectures 58 bool IsGigaProcessor; 59 bool Has64BitSupport; 60 bool Use64BitRegs; 61 bool IsPPC64; 62 bool HasAltivec; 63 bool HasFSQRT; 64 bool HasSTFIWX; 65 bool HasLazyResolverStubs; 66 bool IsJITCodeModel; 67 68 /// DarwinVers - Nonzero if this is a darwin platform. Otherwise, the numeric 69 /// version of the platform, e.g. 8 = 10.4 (Tiger), 9 = 10.5 (Leopard), etc. 70 unsigned char DarwinVers; // Is any darwin-ppc platform. 71 public: 72 /// This constructor initializes the data members to match that 73 /// of the specified triple. 74 /// 75 PPCSubtarget(const std::string &TT, const std::string &FS, bool is64Bit); 76 77 /// ParseSubtargetFeatures - Parses features string setting specified 78 /// subtarget options. Definition of function is auto generated by tblgen. 79 std::string ParseSubtargetFeatures(const std::string &FS, 80 const std::string &CPU); 81 82 83 /// SetJITMode - This is called to inform the subtarget info that we are 84 /// producing code for the JIT. 85 void SetJITMode(); 86 87 /// getStackAlignment - Returns the minimum alignment known to hold of the 88 /// stack frame on entry to the function and which must be maintained by every 89 /// function for this subtarget. getStackAlignment()90 unsigned getStackAlignment() const { return StackAlignment; } 91 92 /// getDarwinDirective - Returns the -m directive specified for the cpu. 93 /// getDarwinDirective()94 unsigned getDarwinDirective() const { return DarwinDirective; } 95 96 /// getInstrItins - Return the instruction itineraies based on subtarget 97 /// selection. getInstrItineraryData()98 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; } 99 100 /// getTargetDataString - Return the pointer size and type alignment 101 /// properties of this subtarget. getTargetDataString()102 const char *getTargetDataString() const { 103 // Note, the alignment values for f64 and i64 on ppc64 in Darwin 104 // documentation are wrong; these are correct (i.e. "what gcc does"). 105 return isPPC64() ? "E-p:64:64-f64:64:64-i64:64:64-f128:64:128-n32:64" 106 : "E-p:32:32-f64:32:64-i64:32:64-f128:64:128-n32"; 107 } 108 109 /// isPPC64 - Return true if we are generating code for 64-bit pointer mode. 110 /// isPPC64()111 bool isPPC64() const { return IsPPC64; } 112 113 /// has64BitSupport - Return true if the selected CPU supports 64-bit 114 /// instructions, regardless of whether we are in 32-bit or 64-bit mode. has64BitSupport()115 bool has64BitSupport() const { return Has64BitSupport; } 116 117 /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit 118 /// registers in 32-bit mode when possible. This can only true if 119 /// has64BitSupport() returns true. use64BitRegs()120 bool use64BitRegs() const { return Use64BitRegs; } 121 122 /// hasLazyResolverStub - Return true if accesses to the specified global have 123 /// to go through a dyld lazy resolution stub. This means that an extra load 124 /// is required to get the address of the global. 125 bool hasLazyResolverStub(const GlobalValue *GV, 126 const TargetMachine &TM) const; 127 128 // isJITCodeModel - True if we're generating code for the JIT isJITCodeModel()129 bool isJITCodeModel() const { return IsJITCodeModel; } 130 131 // Specific obvious features. hasFSQRT()132 bool hasFSQRT() const { return HasFSQRT; } hasSTFIWX()133 bool hasSTFIWX() const { return HasSTFIWX; } hasAltivec()134 bool hasAltivec() const { return HasAltivec; } isGigaProcessor()135 bool isGigaProcessor() const { return IsGigaProcessor; } 136 137 /// isDarwin - True if this is any darwin platform. isDarwin()138 bool isDarwin() const { return DarwinVers != 0; } 139 /// isDarwin - True if this is darwin9 (leopard, 10.5) or above. isDarwin9()140 bool isDarwin9() const { return DarwinVers >= 9; } 141 142 /// getDarwinVers - Return the darwin version number, 8 = tiger, 9 = leopard. getDarwinVers()143 unsigned getDarwinVers() const { return DarwinVers; } 144 isDarwinABI()145 bool isDarwinABI() const { return isDarwin(); } isSVR4ABI()146 bool isSVR4ABI() const { return !isDarwin(); } 147 148 }; 149 } // End llvm namespace 150 151 #endif 152