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 Module; 00043 class GlobalValue; 00044 class TargetMachine; 00045 00046 class PPCSubtarget : public TargetSubtarget { 00047 public: 00048 enum AsmWriterFlavorTy { 00049 OldMnemonic, NewMnemonic, Unset 00050 }; 00051 protected: 00052 const TargetMachine &TM; 00053 00054 /// stackAlignment - The minimum alignment known to hold of the stack frame on 00055 /// entry to the function and which must be maintained by every function. 00056 unsigned StackAlignment; 00057 00058 /// Selected instruction itineraries (one entry per itinerary class.) 00059 InstrItineraryData InstrItins; 00060 00061 /// Which cpu directive was used. 00062 unsigned DarwinDirective; 00063 00064 /// AsmFlavor - Which PPC asm dialect to use. 00065 AsmWriterFlavorTy AsmFlavor; 00066 00067 /// Used by the ISel to turn in optimizations for POWER4-derived architectures 00068 bool IsGigaProcessor; 00069 bool Has64BitSupport; 00070 bool Use64BitRegs; 00071 bool IsPPC64; 00072 bool HasAltivec; 00073 bool HasFSQRT; 00074 bool HasSTFIWX; 00075 bool HasLazyResolverStubs; 00076 00077 /// DarwinVers - Nonzero if this is a darwin platform. Otherwise, the numeric 00078 /// version of the platform, e.g. 8 = 10.4 (Tiger), 9 = 10.5 (Leopard), etc. 00079 unsigned char DarwinVers; // Is any darwin-ppc platform. 00080 public: 00081 /// This constructor initializes the data members to match that 00082 /// of the specified module. 00083 /// 00084 PPCSubtarget(const TargetMachine &TM, const Module &M, 00085 const std::string &FS, bool is64Bit); 00086 00087 /// ParseSubtargetFeatures - Parses features string setting specified 00088 /// subtarget options. Definition of function is auto generated by tblgen. 00089 void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU); 00090 00091 /// SetJITMode - This is called to inform the subtarget info that we are 00092 /// producing code for the JIT. 00093 void SetJITMode(); 00094 00095 /// getStackAlignment - Returns the minimum alignment known to hold of the 00096 /// stack frame on entry to the function and which must be maintained by every 00097 /// function for this subtarget. 00098 unsigned getStackAlignment() const { return StackAlignment; } 00099 00100 /// getDarwinDirective - Returns the -m directive specified for the cpu. 00101 /// 00102 unsigned getDarwinDirective() const { return DarwinDirective; } 00103 00104 /// getInstrItins - Return the instruction itineraies based on subtarget 00105 /// selection. 00106 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; } 00107 00108 /// getTargetDataString - Return the pointer size and type alignment 00109 /// properties of this subtarget. 00110 const char *getTargetDataString() const { 00111 return isPPC64() ? "E-p:64:64-f64:32:64-i64:32:64-f128:64:128" 00112 : "E-p:32:32-f64:32:64-i64:32:64-f128:64:128"; 00113 } 00114 00115 /// isPPC64 - Return true if we are generating code for 64-bit pointer mode. 00116 /// 00117 bool isPPC64() const { return IsPPC64; } 00118 00119 /// has64BitSupport - Return true if the selected CPU supports 64-bit 00120 /// instructions, regardless of whether we are in 32-bit or 64-bit mode. 00121 bool has64BitSupport() const { return Has64BitSupport; } 00122 00123 /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit 00124 /// registers in 32-bit mode when possible. This can only true if 00125 /// has64BitSupport() returns true. 00126 bool use64BitRegs() const { return Use64BitRegs; } 00127 00128 /// hasLazyResolverStub - Return true if accesses to the specified global have 00129 /// to go through a dyld lazy resolution stub. This means that an extra load 00130 /// is required to get the address of the global. 00131 bool hasLazyResolverStub(const GlobalValue *GV) const; 00132 00133 // Specific obvious features. 00134 bool hasFSQRT() const { return HasFSQRT; } 00135 bool hasSTFIWX() const { return HasSTFIWX; } 00136 bool hasAltivec() const { return HasAltivec; } 00137 bool isGigaProcessor() const { return IsGigaProcessor; } 00138 00139 /// isDarwin - True if this is any darwin platform. 00140 bool isDarwin() const { return DarwinVers != 0; } 00141 /// isDarwin - True if this is darwin9 (leopard, 10.5) or above. 00142 bool isDarwin9() const { return DarwinVers >= 9; } 00143 00144 /// getDarwinVers - Return the darwin version number, 8 = tiger, 9 = leopard. 00145 unsigned getDarwinVers() const { return DarwinVers; } 00146 00147 bool isMachoABI() const { return isDarwin() || IsPPC64; } 00148 bool isELF32_ABI() const { return !isDarwin() && !IsPPC64; } 00149 00150 unsigned getAsmFlavor() const { 00151 return AsmFlavor != Unset ? unsigned(AsmFlavor) : 0; 00152 } 00153 }; 00154 } // End llvm namespace 00155 00156 #endif