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 SystemZCallingConventionRegisters *SpecialRegisters; 81 SystemZInstrInfo InstrInfo; 82 SystemZTargetLowering TLInfo; 83 SystemZSelectionDAGInfo TSInfo; 84 SystemZFrameLowering FrameLowering; 85 86 SystemZSubtarget &initializeSubtargetDependencies(StringRef CPU, 87 StringRef FS); 88 SystemZCallingConventionRegisters *initializeSpecialRegisters(void); 89 90 public: 91 SystemZSubtarget(const Triple &TT, const std::string &CPU, 92 const std::string &FS, const TargetMachine &TM); 93 94 ~SystemZSubtarget(); 95 96 SystemZCallingConventionRegisters *getSpecialRegisters() const { 97 assert(SpecialRegisters && "Unsupported SystemZ calling convention"); 98 return SpecialRegisters; 99 } 100 101 const TargetFrameLowering *getFrameLowering() const override { 102 return &FrameLowering; 103 } 104 const SystemZInstrInfo *getInstrInfo() const override { return &InstrInfo; } 105 const SystemZRegisterInfo *getRegisterInfo() const override { 106 return &InstrInfo.getRegisterInfo(); 107 } 108 const SystemZTargetLowering *getTargetLowering() const override { 109 return &TLInfo; 110 } 111 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override { 112 return &TSInfo; 113 } 114 115 // True if the subtarget should run MachineScheduler after aggressive 116 // coalescing. This currently replaces the SelectionDAG scheduler with the 117 // "source" order scheduler. 118 bool enableMachineScheduler() const override { return true; } 119 120 // This is important for reducing register pressure in vector code. 121 bool useAA() const override { return true; } 122 123 // Always enable the early if-conversion pass. 124 bool enableEarlyIfConversion() const override { return true; } 125 126 // Enable tracking of subregister liveness in register allocator. 127 bool enableSubRegLiveness() const override; 128 129 // Automatically generated by tblgen. 130 void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS); 131 132 // Return true if the target has the distinct-operands facility. 133 bool hasDistinctOps() const { return HasDistinctOps; } 134 135 // Return true if the target has the load/store-on-condition facility. 136 bool hasLoadStoreOnCond() const { return HasLoadStoreOnCond; } 137 138 // Return true if the target has the load/store-on-condition facility 2. 139 bool hasLoadStoreOnCond2() const { return HasLoadStoreOnCond2; } 140 141 // Return true if the target has the high-word facility. 142 bool hasHighWord() const { return HasHighWord; } 143 144 // Return true if the target has the floating-point extension facility. 145 bool hasFPExtension() const { return HasFPExtension; } 146 147 // Return true if the target has the population-count facility. 148 bool hasPopulationCount() const { return HasPopulationCount; } 149 150 // Return true if the target has the message-security-assist 151 // extension facility 3. 152 bool hasMessageSecurityAssist3() const { return HasMessageSecurityAssist3; } 153 154 // Return true if the target has the message-security-assist 155 // extension facility 4. 156 bool hasMessageSecurityAssist4() const { return HasMessageSecurityAssist4; } 157 158 // Return true if the target has the reset-reference-bits-multiple facility. 159 bool hasResetReferenceBitsMultiple() const { 160 return HasResetReferenceBitsMultiple; 161 } 162 163 // Return true if the target has the fast-serialization facility. 164 bool hasFastSerialization() const { return HasFastSerialization; } 165 166 // Return true if the target has interlocked-access facility 1. 167 bool hasInterlockedAccess1() const { return HasInterlockedAccess1; } 168 169 // Return true if the target has the miscellaneous-extensions facility. 170 bool hasMiscellaneousExtensions() const { 171 return HasMiscellaneousExtensions; 172 } 173 174 // Return true if the target has the execution-hint facility. 175 bool hasExecutionHint() const { return HasExecutionHint; } 176 177 // Return true if the target has the load-and-trap facility. 178 bool hasLoadAndTrap() const { return HasLoadAndTrap; } 179 180 // Return true if the target has the transactional-execution facility. 181 bool hasTransactionalExecution() const { return HasTransactionalExecution; } 182 183 // Return true if the target has the processor-assist facility. 184 bool hasProcessorAssist() const { return HasProcessorAssist; } 185 186 // Return true if the target has the DFP zoned-conversion facility. 187 bool hasDFPZonedConversion() const { return HasDFPZonedConversion; } 188 189 // Return true if the target has the enhanced-DAT facility 2. 190 bool hasEnhancedDAT2() const { return HasEnhancedDAT2; } 191 192 // Return true if the target has the load-and-zero-rightmost-byte facility. 193 bool hasLoadAndZeroRightmostByte() const { 194 return HasLoadAndZeroRightmostByte; 195 } 196 197 // Return true if the target has the message-security-assist 198 // extension facility 5. 199 bool hasMessageSecurityAssist5() const { return HasMessageSecurityAssist5; } 200 201 // Return true if the target has the DFP packed-conversion facility. 202 bool hasDFPPackedConversion() const { return HasDFPPackedConversion; } 203 204 // Return true if the target has the vector facility. 205 bool hasVector() const { return HasVector; } 206 207 // Return true if the target has the miscellaneous-extensions facility 2. 208 bool hasMiscellaneousExtensions2() const { 209 return HasMiscellaneousExtensions2; 210 } 211 212 // Return true if the target has the guarded-storage facility. 213 bool hasGuardedStorage() const { return HasGuardedStorage; } 214 215 // Return true if the target has the message-security-assist 216 // extension facility 7. 217 bool hasMessageSecurityAssist7() const { return HasMessageSecurityAssist7; } 218 219 // Return true if the target has the message-security-assist 220 // extension facility 8. 221 bool hasMessageSecurityAssist8() const { return HasMessageSecurityAssist8; } 222 223 // Return true if the target has the vector-enhancements facility 1. 224 bool hasVectorEnhancements1() const { return HasVectorEnhancements1; } 225 226 // Return true if the target has the vector-packed-decimal facility. 227 bool hasVectorPackedDecimal() const { return HasVectorPackedDecimal; } 228 229 // Return true if the target has the insert-reference-bits-multiple facility. 230 bool hasInsertReferenceBitsMultiple() const { 231 return HasInsertReferenceBitsMultiple; 232 } 233 234 // Return true if the target has the miscellaneous-extensions facility 3. 235 bool hasMiscellaneousExtensions3() const { 236 return HasMiscellaneousExtensions3; 237 } 238 239 // Return true if the target has the message-security-assist 240 // extension facility 9. 241 bool hasMessageSecurityAssist9() const { return HasMessageSecurityAssist9; } 242 243 // Return true if the target has the vector-enhancements facility 2. 244 bool hasVectorEnhancements2() const { return HasVectorEnhancements2; } 245 246 // Return true if the target has the vector-packed-decimal 247 // enhancement facility. 248 bool hasVectorPackedDecimalEnhancement() const { 249 return HasVectorPackedDecimalEnhancement; 250 } 251 252 // Return true if the target has the enhanced-sort facility. 253 bool hasEnhancedSort() const { return HasEnhancedSort; } 254 255 // Return true if the target has the deflate-conversion facility. 256 bool hasDeflateConversion() const { return HasDeflateConversion; } 257 258 // Return true if the target has the vector-packed-decimal 259 // enhancement facility 2. 260 bool hasVectorPackedDecimalEnhancement2() const { 261 return HasVectorPackedDecimalEnhancement2; 262 } 263 264 // Return true if the target has the NNP-assist facility. 265 bool hasNNPAssist() const { return HasNNPAssist; } 266 267 // Return true if the target has the BEAR-enhancement facility. 268 bool hasBEAREnhancement() const { return HasBEAREnhancement; } 269 270 // Return true if the target has the reset-DAT-protection facility. 271 bool hasResetDATProtection() const { return HasResetDATProtection; } 272 273 // Return true if the target has the processor-activity-instrumentation 274 // facility. 275 bool hasProcessorActivityInstrumentation() const { 276 return HasProcessorActivityInstrumentation; 277 } 278 279 // Return true if soft float should be used. 280 bool hasSoftFloat() const { return HasSoftFloat; } 281 282 // Return true if GV can be accessed using LARL for reloc model RM 283 // and code model CM. 284 bool isPC32DBLSymbol(const GlobalValue *GV, CodeModel::Model CM) const; 285 286 bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); } 287 288 // Returns TRUE if we are generating GOFF object code 289 bool isTargetGOFF() const { return TargetTriple.isOSBinFormatGOFF(); } 290 291 // Returns TRUE if we are using XPLINK64 linkage convention 292 bool isTargetXPLINK64() const { return (isTargetGOFF() && isTargetzOS()); } 293 294 // Returns TRUE if we are generating code for a s390x machine running zOS 295 bool isTargetzOS() const { return TargetTriple.isOSzOS(); } 296 }; 297 } // end namespace llvm 298 299 #endif 300