1 //===-- SystemZSubtarget.h - SystemZ subtarget information -----*- C++ -*--===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file declares the SystemZ specific subclass of TargetSubtargetInfo. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZSUBTARGET_H 14 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZSUBTARGET_H 15 16 #include "SystemZFrameLowering.h" 17 #include "SystemZISelLowering.h" 18 #include "SystemZInstrInfo.h" 19 #include "SystemZRegisterInfo.h" 20 #include "SystemZSelectionDAGInfo.h" 21 #include "llvm/ADT/Triple.h" 22 #include "llvm/CodeGen/TargetSubtargetInfo.h" 23 #include "llvm/IR/DataLayout.h" 24 #include <string> 25 26 #define GET_SUBTARGETINFO_HEADER 27 #include "SystemZGenSubtargetInfo.inc" 28 29 namespace llvm { 30 class GlobalValue; 31 class StringRef; 32 33 class SystemZSubtarget : public SystemZGenSubtargetInfo { 34 virtual void anchor(); 35 protected: 36 bool HasDistinctOps; 37 bool HasLoadStoreOnCond; 38 bool HasHighWord; 39 bool HasFPExtension; 40 bool HasPopulationCount; 41 bool HasMessageSecurityAssist3; 42 bool HasMessageSecurityAssist4; 43 bool HasResetReferenceBitsMultiple; 44 bool HasFastSerialization; 45 bool HasInterlockedAccess1; 46 bool HasMiscellaneousExtensions; 47 bool HasExecutionHint; 48 bool HasLoadAndTrap; 49 bool HasTransactionalExecution; 50 bool HasProcessorAssist; 51 bool HasDFPZonedConversion; 52 bool HasEnhancedDAT2; 53 bool HasVector; 54 bool HasLoadStoreOnCond2; 55 bool HasLoadAndZeroRightmostByte; 56 bool HasMessageSecurityAssist5; 57 bool HasDFPPackedConversion; 58 bool HasMiscellaneousExtensions2; 59 bool HasGuardedStorage; 60 bool HasMessageSecurityAssist7; 61 bool HasMessageSecurityAssist8; 62 bool HasVectorEnhancements1; 63 bool HasVectorPackedDecimal; 64 bool HasInsertReferenceBitsMultiple; 65 bool HasMiscellaneousExtensions3; 66 bool HasMessageSecurityAssist9; 67 bool HasVectorEnhancements2; 68 bool HasVectorPackedDecimalEnhancement; 69 bool HasEnhancedSort; 70 bool HasDeflateConversion; 71 bool HasVectorPackedDecimalEnhancement2; 72 bool HasNNPAssist; 73 bool HasBEAREnhancement; 74 bool HasResetDATProtection; 75 bool HasProcessorActivityInstrumentation; 76 bool HasSoftFloat; 77 78 private: 79 Triple TargetTriple; 80 std::unique_ptr<SystemZCallingConventionRegisters> SpecialRegisters; 81 SystemZInstrInfo InstrInfo; 82 SystemZTargetLowering TLInfo; 83 SystemZSelectionDAGInfo TSInfo; 84 std::unique_ptr<const SystemZFrameLowering> FrameLowering; 85 86 SystemZSubtarget &initializeSubtargetDependencies(StringRef CPU, 87 StringRef FS); 88 SystemZCallingConventionRegisters *initializeSpecialRegisters(); 89 90 public: 91 SystemZSubtarget(const Triple &TT, const std::string &CPU, 92 const std::string &FS, const TargetMachine &TM); 93 94 SystemZCallingConventionRegisters *getSpecialRegisters() const { 95 assert(SpecialRegisters && "Unsupported SystemZ calling convention"); 96 return SpecialRegisters.get(); 97 } 98 99 template <class SR> SR &getSpecialRegisters() const { 100 return *static_cast<SR *>(getSpecialRegisters()); 101 } 102 103 const TargetFrameLowering *getFrameLowering() const override { 104 return FrameLowering.get(); 105 } 106 107 template <class TFL> const TFL *getFrameLowering() const { 108 return static_cast<const TFL *>(getFrameLowering()); 109 } 110 111 const SystemZInstrInfo *getInstrInfo() const override { return &InstrInfo; } 112 const SystemZRegisterInfo *getRegisterInfo() const override { 113 return &InstrInfo.getRegisterInfo(); 114 } 115 const SystemZTargetLowering *getTargetLowering() const override { 116 return &TLInfo; 117 } 118 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override { 119 return &TSInfo; 120 } 121 122 // True if the subtarget should run MachineScheduler after aggressive 123 // coalescing. This currently replaces the SelectionDAG scheduler with the 124 // "source" order scheduler. 125 bool enableMachineScheduler() const override { return true; } 126 127 // This is important for reducing register pressure in vector code. 128 bool useAA() const override { return true; } 129 130 // Always enable the early if-conversion pass. 131 bool enableEarlyIfConversion() const override { return true; } 132 133 // Enable tracking of subregister liveness in register allocator. 134 bool enableSubRegLiveness() const override; 135 136 // Automatically generated by tblgen. 137 void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS); 138 139 // Return true if the target has the distinct-operands facility. 140 bool hasDistinctOps() const { return HasDistinctOps; } 141 142 // Return true if the target has the load/store-on-condition facility. 143 bool hasLoadStoreOnCond() const { return HasLoadStoreOnCond; } 144 145 // Return true if the target has the load/store-on-condition facility 2. 146 bool hasLoadStoreOnCond2() const { return HasLoadStoreOnCond2; } 147 148 // Return true if the target has the high-word facility. 149 bool hasHighWord() const { return HasHighWord; } 150 151 // Return true if the target has the floating-point extension facility. 152 bool hasFPExtension() const { return HasFPExtension; } 153 154 // Return true if the target has the population-count facility. 155 bool hasPopulationCount() const { return HasPopulationCount; } 156 157 // Return true if the target has the message-security-assist 158 // extension facility 3. 159 bool hasMessageSecurityAssist3() const { return HasMessageSecurityAssist3; } 160 161 // Return true if the target has the message-security-assist 162 // extension facility 4. 163 bool hasMessageSecurityAssist4() const { return HasMessageSecurityAssist4; } 164 165 // Return true if the target has the reset-reference-bits-multiple facility. 166 bool hasResetReferenceBitsMultiple() const { 167 return HasResetReferenceBitsMultiple; 168 } 169 170 // Return true if the target has the fast-serialization facility. 171 bool hasFastSerialization() const { return HasFastSerialization; } 172 173 // Return true if the target has interlocked-access facility 1. 174 bool hasInterlockedAccess1() const { return HasInterlockedAccess1; } 175 176 // Return true if the target has the miscellaneous-extensions facility. 177 bool hasMiscellaneousExtensions() const { 178 return HasMiscellaneousExtensions; 179 } 180 181 // Return true if the target has the execution-hint facility. 182 bool hasExecutionHint() const { return HasExecutionHint; } 183 184 // Return true if the target has the load-and-trap facility. 185 bool hasLoadAndTrap() const { return HasLoadAndTrap; } 186 187 // Return true if the target has the transactional-execution facility. 188 bool hasTransactionalExecution() const { return HasTransactionalExecution; } 189 190 // Return true if the target has the processor-assist facility. 191 bool hasProcessorAssist() const { return HasProcessorAssist; } 192 193 // Return true if the target has the DFP zoned-conversion facility. 194 bool hasDFPZonedConversion() const { return HasDFPZonedConversion; } 195 196 // Return true if the target has the enhanced-DAT facility 2. 197 bool hasEnhancedDAT2() const { return HasEnhancedDAT2; } 198 199 // Return true if the target has the load-and-zero-rightmost-byte facility. 200 bool hasLoadAndZeroRightmostByte() const { 201 return HasLoadAndZeroRightmostByte; 202 } 203 204 // Return true if the target has the message-security-assist 205 // extension facility 5. 206 bool hasMessageSecurityAssist5() const { return HasMessageSecurityAssist5; } 207 208 // Return true if the target has the DFP packed-conversion facility. 209 bool hasDFPPackedConversion() const { return HasDFPPackedConversion; } 210 211 // Return true if the target has the vector facility. 212 bool hasVector() const { return HasVector; } 213 214 // Return true if the target has the miscellaneous-extensions facility 2. 215 bool hasMiscellaneousExtensions2() const { 216 return HasMiscellaneousExtensions2; 217 } 218 219 // Return true if the target has the guarded-storage facility. 220 bool hasGuardedStorage() const { return HasGuardedStorage; } 221 222 // Return true if the target has the message-security-assist 223 // extension facility 7. 224 bool hasMessageSecurityAssist7() const { return HasMessageSecurityAssist7; } 225 226 // Return true if the target has the message-security-assist 227 // extension facility 8. 228 bool hasMessageSecurityAssist8() const { return HasMessageSecurityAssist8; } 229 230 // Return true if the target has the vector-enhancements facility 1. 231 bool hasVectorEnhancements1() const { return HasVectorEnhancements1; } 232 233 // Return true if the target has the vector-packed-decimal facility. 234 bool hasVectorPackedDecimal() const { return HasVectorPackedDecimal; } 235 236 // Return true if the target has the insert-reference-bits-multiple facility. 237 bool hasInsertReferenceBitsMultiple() const { 238 return HasInsertReferenceBitsMultiple; 239 } 240 241 // Return true if the target has the miscellaneous-extensions facility 3. 242 bool hasMiscellaneousExtensions3() const { 243 return HasMiscellaneousExtensions3; 244 } 245 246 // Return true if the target has the message-security-assist 247 // extension facility 9. 248 bool hasMessageSecurityAssist9() const { return HasMessageSecurityAssist9; } 249 250 // Return true if the target has the vector-enhancements facility 2. 251 bool hasVectorEnhancements2() const { return HasVectorEnhancements2; } 252 253 // Return true if the target has the vector-packed-decimal 254 // enhancement facility. 255 bool hasVectorPackedDecimalEnhancement() const { 256 return HasVectorPackedDecimalEnhancement; 257 } 258 259 // Return true if the target has the enhanced-sort facility. 260 bool hasEnhancedSort() const { return HasEnhancedSort; } 261 262 // Return true if the target has the deflate-conversion facility. 263 bool hasDeflateConversion() const { return HasDeflateConversion; } 264 265 // Return true if the target has the vector-packed-decimal 266 // enhancement facility 2. 267 bool hasVectorPackedDecimalEnhancement2() const { 268 return HasVectorPackedDecimalEnhancement2; 269 } 270 271 // Return true if the target has the NNP-assist facility. 272 bool hasNNPAssist() const { return HasNNPAssist; } 273 274 // Return true if the target has the BEAR-enhancement facility. 275 bool hasBEAREnhancement() const { return HasBEAREnhancement; } 276 277 // Return true if the target has the reset-DAT-protection facility. 278 bool hasResetDATProtection() const { return HasResetDATProtection; } 279 280 // Return true if the target has the processor-activity-instrumentation 281 // facility. 282 bool hasProcessorActivityInstrumentation() const { 283 return HasProcessorActivityInstrumentation; 284 } 285 286 // Return true if soft float should be used. 287 bool hasSoftFloat() const { return HasSoftFloat; } 288 289 // Return true if GV can be accessed using LARL for reloc model RM 290 // and code model CM. 291 bool isPC32DBLSymbol(const GlobalValue *GV, CodeModel::Model CM) const; 292 293 bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); } 294 295 // Returns TRUE if we are generating GOFF object code 296 bool isTargetGOFF() const { return TargetTriple.isOSBinFormatGOFF(); } 297 298 // Returns TRUE if we are using XPLINK64 linkage convention 299 bool isTargetXPLINK64() const { return (isTargetGOFF() && isTargetzOS()); } 300 301 // Returns TRUE if we are generating code for a s390x machine running zOS 302 bool isTargetzOS() const { return TargetTriple.isOSzOS(); } 303 }; 304 } // end namespace llvm 305 306 #endif 307