Matt Arsenault | 0c90e95 | 2015-11-06 18:17:45 +0000 | [diff] [blame] | 1 | //=====-- AMDGPUSubtarget.h - Define Subtarget for AMDGPU ------*- C++ -*-====// |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 6 | // |
| 7 | //==-----------------------------------------------------------------------===// |
| 8 | // |
| 9 | /// \file |
Adrian Prantl | 5f8f34e4 | 2018-05-01 15:54:18 +0000 | [diff] [blame] | 10 | /// AMDGPU specific subclass of TargetSubtarget. |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Matt Arsenault | 0c90e95 | 2015-11-06 18:17:45 +0000 | [diff] [blame] | 14 | #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H |
| 15 | #define LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H |
Matt Arsenault | f59e538 | 2015-11-06 18:23:00 +0000 | [diff] [blame] | 16 | |
Tom Stellard | a6c6e1b | 2013-06-07 20:37:48 +0000 | [diff] [blame] | 17 | #include "AMDGPU.h" |
Quentin Colombet | 61d71a1 | 2017-08-15 22:31:51 +0000 | [diff] [blame] | 18 | #include "AMDGPUCallLowering.h" |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 19 | #include "R600FrameLowering.h" |
Chandler Carruth | 6bda14b | 2017-06-06 11:49:48 +0000 | [diff] [blame] | 20 | #include "R600ISelLowering.h" |
| 21 | #include "R600InstrInfo.h" |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 22 | #include "SIFrameLowering.h" |
Chandler Carruth | 6bda14b | 2017-06-06 11:49:48 +0000 | [diff] [blame] | 23 | #include "SIISelLowering.h" |
| 24 | #include "SIInstrInfo.h" |
Tom Stellard | 347ac79 | 2015-06-26 21:15:07 +0000 | [diff] [blame] | 25 | #include "Utils/AMDGPUBaseInfo.h" |
Eugene Zelenko | 2bc2f33 | 2016-12-09 22:06:55 +0000 | [diff] [blame] | 26 | #include "llvm/ADT/Triple.h" |
Quentin Colombet | 61d71a1 | 2017-08-15 22:31:51 +0000 | [diff] [blame] | 27 | #include "llvm/CodeGen/GlobalISel/InstructionSelector.h" |
| 28 | #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h" |
| 29 | #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h" |
Eugene Zelenko | 2bc2f33 | 2016-12-09 22:06:55 +0000 | [diff] [blame] | 30 | #include "llvm/CodeGen/MachineFunction.h" |
Matt Arsenault | 56684d4 | 2016-08-11 17:31:42 +0000 | [diff] [blame] | 31 | #include "llvm/CodeGen/SelectionDAGTargetInfo.h" |
Eugene Zelenko | 2bc2f33 | 2016-12-09 22:06:55 +0000 | [diff] [blame] | 32 | #include "llvm/MC/MCInstrItineraries.h" |
| 33 | #include "llvm/Support/MathExtras.h" |
| 34 | #include <cassert> |
| 35 | #include <cstdint> |
| 36 | #include <memory> |
| 37 | #include <utility> |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 38 | |
| 39 | #define GET_SUBTARGETINFO_HEADER |
| 40 | #include "AMDGPUGenSubtargetInfo.inc" |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 41 | #define GET_SUBTARGETINFO_HEADER |
| 42 | #include "R600GenSubtargetInfo.inc" |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 43 | |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 44 | namespace llvm { |
| 45 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 46 | class StringRef; |
Tom Stellard | e99fb65 | 2015-01-20 19:33:04 +0000 | [diff] [blame] | 47 | |
Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 48 | class AMDGPUSubtarget { |
| 49 | public: |
| 50 | enum Generation { |
| 51 | R600 = 0, |
| 52 | R700 = 1, |
Matt Arsenault | 4bec7d4 | 2018-07-20 09:05:08 +0000 | [diff] [blame] | 53 | EVERGREEN = 2, |
Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 54 | NORTHERN_ISLANDS = 3, |
| 55 | SOUTHERN_ISLANDS = 4, |
| 56 | SEA_ISLANDS = 5, |
| 57 | VOLCANIC_ISLANDS = 6, |
Stanislav Mekhanoshin | cee607e | 2019-04-24 17:03:15 +0000 | [diff] [blame] | 58 | GFX9 = 7, |
| 59 | GFX10 = 8 |
Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 62 | private: |
| 63 | Triple TargetTriple; |
| 64 | |
| 65 | protected: |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 66 | bool Has16BitInsts; |
| 67 | bool HasMadMixInsts; |
| 68 | bool FP32Denormals; |
| 69 | bool FPExceptions; |
| 70 | bool HasSDWA; |
| 71 | bool HasVOP3PInsts; |
| 72 | bool HasMulI24; |
| 73 | bool HasMulU24; |
Matt Arsenault | 6c7ba82 | 2018-08-15 21:03:55 +0000 | [diff] [blame] | 74 | bool HasInv2PiInlineImm; |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 75 | bool HasFminFmaxLegacy; |
| 76 | bool EnablePromoteAlloca; |
David Stuttard | 20de3e9 | 2018-09-14 10:27:19 +0000 | [diff] [blame] | 77 | bool HasTrigReducedRange; |
Stanislav Mekhanoshin | 2594fa8 | 2019-07-31 01:07:10 +0000 | [diff] [blame] | 78 | unsigned MaxWavesPerEU; |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 79 | int LocalMemorySize; |
| 80 | unsigned WavefrontSize; |
| 81 | |
| 82 | public: |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 83 | AMDGPUSubtarget(const Triple &TT); |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 84 | |
Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 85 | static const AMDGPUSubtarget &get(const MachineFunction &MF); |
| 86 | static const AMDGPUSubtarget &get(const TargetMachine &TM, |
Matt Arsenault | 4bec7d4 | 2018-07-20 09:05:08 +0000 | [diff] [blame] | 87 | const Function &F); |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 88 | |
| 89 | /// \returns Default range flat work group size for a calling convention. |
| 90 | std::pair<unsigned, unsigned> getDefaultFlatWorkGroupSize(CallingConv::ID CC) const; |
| 91 | |
| 92 | /// \returns Subtarget's default pair of minimum/maximum flat work group sizes |
| 93 | /// for function \p F, or minimum/maximum flat work group sizes explicitly |
| 94 | /// requested using "amdgpu-flat-work-group-size" attribute attached to |
| 95 | /// function \p F. |
| 96 | /// |
| 97 | /// \returns Subtarget's default values if explicitly requested values cannot |
| 98 | /// be converted to integer, or violate subtarget's specifications. |
| 99 | std::pair<unsigned, unsigned> getFlatWorkGroupSizes(const Function &F) const; |
| 100 | |
| 101 | /// \returns Subtarget's default pair of minimum/maximum number of waves per |
| 102 | /// execution unit for function \p F, or minimum/maximum number of waves per |
| 103 | /// execution unit explicitly requested using "amdgpu-waves-per-eu" attribute |
| 104 | /// attached to function \p F. |
| 105 | /// |
| 106 | /// \returns Subtarget's default values if explicitly requested values cannot |
| 107 | /// be converted to integer, violate subtarget's specifications, or are not |
| 108 | /// compatible with minimum/maximum number of waves limited by flat work group |
| 109 | /// size, register usage, and/or lds usage. |
| 110 | std::pair<unsigned, unsigned> getWavesPerEU(const Function &F) const; |
| 111 | |
| 112 | /// Return the amount of LDS that can be used that will not restrict the |
| 113 | /// occupancy lower than WaveCount. |
| 114 | unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount, |
| 115 | const Function &) const; |
| 116 | |
| 117 | /// Inverse of getMaxLocalMemWithWaveCount. Return the maximum wavecount if |
| 118 | /// the given LDS memory size is the only constraint. |
| 119 | unsigned getOccupancyWithLocalMemSize(uint32_t Bytes, const Function &) const; |
| 120 | |
| 121 | unsigned getOccupancyWithLocalMemSize(const MachineFunction &MF) const; |
| 122 | |
| 123 | bool isAmdHsaOS() const { |
| 124 | return TargetTriple.getOS() == Triple::AMDHSA; |
| 125 | } |
| 126 | |
| 127 | bool isAmdPalOS() const { |
| 128 | return TargetTriple.getOS() == Triple::AMDPAL; |
| 129 | } |
| 130 | |
Tom Stellard | ec4feae | 2018-07-06 17:16:17 +0000 | [diff] [blame] | 131 | bool isMesa3DOS() const { |
| 132 | return TargetTriple.getOS() == Triple::Mesa3D; |
| 133 | } |
| 134 | |
| 135 | bool isMesaKernel(const Function &F) const { |
| 136 | return isMesa3DOS() && !AMDGPU::isShader(F.getCallingConv()); |
| 137 | } |
| 138 | |
Konstantin Zhuravlyov | aa067cb | 2018-10-04 21:02:16 +0000 | [diff] [blame] | 139 | bool isAmdHsaOrMesa(const Function &F) const { |
Tom Stellard | ec4feae | 2018-07-06 17:16:17 +0000 | [diff] [blame] | 140 | return isAmdHsaOS() || isMesaKernel(F); |
| 141 | } |
| 142 | |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 143 | bool has16BitInsts() const { |
| 144 | return Has16BitInsts; |
| 145 | } |
| 146 | |
| 147 | bool hasMadMixInsts() const { |
| 148 | return HasMadMixInsts; |
| 149 | } |
| 150 | |
| 151 | bool hasFP32Denormals() const { |
| 152 | return FP32Denormals; |
| 153 | } |
| 154 | |
| 155 | bool hasFPExceptions() const { |
| 156 | return FPExceptions; |
| 157 | } |
| 158 | |
| 159 | bool hasSDWA() const { |
| 160 | return HasSDWA; |
| 161 | } |
| 162 | |
| 163 | bool hasVOP3PInsts() const { |
| 164 | return HasVOP3PInsts; |
| 165 | } |
| 166 | |
| 167 | bool hasMulI24() const { |
| 168 | return HasMulI24; |
| 169 | } |
| 170 | |
| 171 | bool hasMulU24() const { |
| 172 | return HasMulU24; |
| 173 | } |
| 174 | |
Matt Arsenault | 6c7ba82 | 2018-08-15 21:03:55 +0000 | [diff] [blame] | 175 | bool hasInv2PiInlineImm() const { |
| 176 | return HasInv2PiInlineImm; |
| 177 | } |
| 178 | |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 179 | bool hasFminFmaxLegacy() const { |
| 180 | return HasFminFmaxLegacy; |
| 181 | } |
| 182 | |
David Stuttard | 20de3e9 | 2018-09-14 10:27:19 +0000 | [diff] [blame] | 183 | bool hasTrigReducedRange() const { |
| 184 | return HasTrigReducedRange; |
| 185 | } |
| 186 | |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 187 | bool isPromoteAllocaEnabled() const { |
| 188 | return EnablePromoteAlloca; |
| 189 | } |
| 190 | |
| 191 | unsigned getWavefrontSize() const { |
| 192 | return WavefrontSize; |
| 193 | } |
| 194 | |
| 195 | int getLocalMemorySize() const { |
| 196 | return LocalMemorySize; |
| 197 | } |
| 198 | |
| 199 | unsigned getAlignmentForImplicitArgPtr() const { |
| 200 | return isAmdHsaOS() ? 8 : 4; |
| 201 | } |
| 202 | |
Tom Stellard | ec4feae | 2018-07-06 17:16:17 +0000 | [diff] [blame] | 203 | /// Returns the offset in bytes from the start of the input buffer |
| 204 | /// of the first explicit kernel argument. |
| 205 | unsigned getExplicitKernelArgOffset(const Function &F) const { |
Konstantin Zhuravlyov | aa067cb | 2018-10-04 21:02:16 +0000 | [diff] [blame] | 206 | return isAmdHsaOrMesa(F) ? 0 : 36; |
Tom Stellard | ec4feae | 2018-07-06 17:16:17 +0000 | [diff] [blame] | 207 | } |
| 208 | |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 209 | /// \returns Maximum number of work groups per compute unit supported by the |
| 210 | /// subtarget and limited by given \p FlatWorkGroupSize. |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 211 | virtual unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const = 0; |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 212 | |
| 213 | /// \returns Minimum flat work group size supported by the subtarget. |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 214 | virtual unsigned getMinFlatWorkGroupSize() const = 0; |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 215 | |
| 216 | /// \returns Maximum flat work group size supported by the subtarget. |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 217 | virtual unsigned getMaxFlatWorkGroupSize() const = 0; |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 218 | |
| 219 | /// \returns Maximum number of waves per execution unit supported by the |
| 220 | /// subtarget and limited by given \p FlatWorkGroupSize. |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 221 | virtual unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const = 0; |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 222 | |
| 223 | /// \returns Minimum number of waves per execution unit supported by the |
| 224 | /// subtarget. |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 225 | virtual unsigned getMinWavesPerEU() const = 0; |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 226 | |
Stanislav Mekhanoshin | 2594fa8 | 2019-07-31 01:07:10 +0000 | [diff] [blame] | 227 | /// \returns Maximum number of waves per execution unit supported by the |
| 228 | /// subtarget without any kind of limitation. |
| 229 | unsigned getMaxWavesPerEU() const { return MaxWavesPerEU; } |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 230 | |
| 231 | /// Creates value range metadata on an workitemid.* inrinsic call or load. |
| 232 | bool makeLIDRangeMetadata(Instruction *I) const; |
| 233 | |
Matt Arsenault | 4bec7d4 | 2018-07-20 09:05:08 +0000 | [diff] [blame] | 234 | /// \returns Number of bytes of arguments that are passed to a shader or |
| 235 | /// kernel in addition to the explicit ones declared for the function. |
| 236 | unsigned getImplicitArgNumBytes(const Function &F) const { |
| 237 | if (isMesaKernel(F)) |
| 238 | return 16; |
| 239 | return AMDGPU::getIntegerAttribute(F, "amdgpu-implicitarg-num-bytes", 0); |
| 240 | } |
| 241 | uint64_t getExplicitKernArgSize(const Function &F, |
| 242 | unsigned &MaxAlign) const; |
| 243 | unsigned getKernArgSegmentSize(const Function &F, |
| 244 | unsigned &MaxAlign) const; |
| 245 | |
Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 246 | virtual ~AMDGPUSubtarget() {} |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 247 | }; |
| 248 | |
Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 249 | class GCNSubtarget : public AMDGPUGenSubtargetInfo, |
| 250 | public AMDGPUSubtarget { |
Stanislav Mekhanoshin | 2594fa8 | 2019-07-31 01:07:10 +0000 | [diff] [blame] | 251 | |
| 252 | using AMDGPUSubtarget::getMaxWavesPerEU; |
| 253 | |
Tom Stellard | a6c6e1b | 2013-06-07 20:37:48 +0000 | [diff] [blame] | 254 | public: |
Wei Ding | 205bfdb | 2017-02-10 02:15:29 +0000 | [diff] [blame] | 255 | enum TrapHandlerAbi { |
| 256 | TrapHandlerAbiNone = 0, |
| 257 | TrapHandlerAbiHsa = 1 |
| 258 | }; |
| 259 | |
Wei Ding | f2cce02 | 2017-02-22 23:22:19 +0000 | [diff] [blame] | 260 | enum TrapID { |
| 261 | TrapIDHardwareReserved = 0, |
| 262 | TrapIDHSADebugTrap = 1, |
| 263 | TrapIDLLVMTrap = 2, |
| 264 | TrapIDLLVMDebugTrap = 3, |
| 265 | TrapIDDebugBreakpoint = 7, |
| 266 | TrapIDDebugReserved8 = 8, |
| 267 | TrapIDDebugReservedFE = 0xfe, |
| 268 | TrapIDDebugReservedFF = 0xff |
Wei Ding | 205bfdb | 2017-02-10 02:15:29 +0000 | [diff] [blame] | 269 | }; |
| 270 | |
| 271 | enum TrapRegValues { |
Wei Ding | f2cce02 | 2017-02-22 23:22:19 +0000 | [diff] [blame] | 272 | LLVMTrapHandlerRegValue = 1 |
Wei Ding | 205bfdb | 2017-02-10 02:15:29 +0000 | [diff] [blame] | 273 | }; |
| 274 | |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 275 | private: |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 276 | /// GlobalISel related APIs. |
| 277 | std::unique_ptr<AMDGPUCallLowering> CallLoweringInfo; |
| 278 | std::unique_ptr<InstructionSelector> InstSelector; |
| 279 | std::unique_ptr<LegalizerInfo> Legalizer; |
| 280 | std::unique_ptr<RegisterBankInfo> RegBankInfo; |
| 281 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 282 | protected: |
| 283 | // Basic subtarget description. |
| 284 | Triple TargetTriple; |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 285 | unsigned Gen; |
Stanislav Mekhanoshin | 06d3b41 | 2018-09-17 16:04:32 +0000 | [diff] [blame] | 286 | InstrItineraryData InstrItins; |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 287 | int LDSBankCount; |
| 288 | unsigned MaxPrivateElementSize; |
| 289 | |
| 290 | // Possibly statically set by tablegen, but may want to be overridden. |
Matt Arsenault | b035a57 | 2015-01-29 19:34:25 +0000 | [diff] [blame] | 291 | bool FastFMAF32; |
Matt Arsenault | e83690c | 2016-01-18 21:13:50 +0000 | [diff] [blame] | 292 | bool HalfRate64Ops; |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 293 | |
| 294 | // Dynamially set bits that enable features. |
Matt Arsenault | a6867fd | 2017-01-23 22:31:03 +0000 | [diff] [blame] | 295 | bool FP64FP16Denormals; |
Changpeng Fang | b41574a | 2015-12-22 20:55:23 +0000 | [diff] [blame] | 296 | bool FlatForGlobal; |
Konstantin Zhuravlyov | be6c0ca | 2017-06-02 17:40:26 +0000 | [diff] [blame] | 297 | bool AutoWaitcntBeforeBarrier; |
Konstantin Zhuravlyov | eda425e | 2017-10-14 15:59:07 +0000 | [diff] [blame] | 298 | bool CodeObjectV3; |
Tom Stellard | 64a9d08 | 2016-10-14 18:10:39 +0000 | [diff] [blame] | 299 | bool UnalignedScratchAccess; |
Matt Arsenault | 7f681ac | 2016-07-01 23:03:44 +0000 | [diff] [blame] | 300 | bool UnalignedBufferAccess; |
Matt Arsenault | e823d92 | 2017-02-18 18:29:53 +0000 | [diff] [blame] | 301 | bool HasApertureRegs; |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 302 | bool EnableXNACK; |
Matt Arsenault | df24c92 | 2019-05-16 14:48:34 +0000 | [diff] [blame] | 303 | bool DoesNotSupportXNACK; |
Stanislav Mekhanoshin | cee607e | 2019-04-24 17:03:15 +0000 | [diff] [blame] | 304 | bool EnableCuMode; |
Wei Ding | 205bfdb | 2017-02-10 02:15:29 +0000 | [diff] [blame] | 305 | bool TrapHandler; |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 306 | |
| 307 | // Used as options. |
Matt Arsenault | 4103328 | 2014-10-10 22:01:59 +0000 | [diff] [blame] | 308 | bool EnableLoadStoreOpt; |
Matt Arsenault | 706f930 | 2015-07-06 16:01:58 +0000 | [diff] [blame] | 309 | bool EnableUnsafeDSOffsetFolding; |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 310 | bool EnableSIScheduler; |
Marek Olsak | a9a58fa | 2018-04-10 22:48:23 +0000 | [diff] [blame] | 311 | bool EnableDS128; |
David Stuttard | f77079f | 2019-01-14 11:55:24 +0000 | [diff] [blame] | 312 | bool EnablePRTStrictNull; |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 313 | bool DumpCode; |
| 314 | |
| 315 | // Subtarget statically properties set by tablegen |
| 316 | bool FP64; |
Jan Vesely | 39aeab4 | 2017-12-04 23:07:28 +0000 | [diff] [blame] | 317 | bool FMA; |
Dmitry Preobrazhensky | e3271ae | 2018-02-05 12:45:43 +0000 | [diff] [blame] | 318 | bool MIMG_R128; |
Tom Stellard | d7e6f13 | 2015-04-08 01:09:26 +0000 | [diff] [blame] | 319 | bool IsGCN; |
Tom Stellard | d7e6f13 | 2015-04-08 01:09:26 +0000 | [diff] [blame] | 320 | bool GCN3Encoding; |
Tom Stellard | d1f0f02 | 2015-04-23 19:33:54 +0000 | [diff] [blame] | 321 | bool CIInsts; |
Stanislav Mekhanoshin | 7895c03 | 2019-04-05 18:24:34 +0000 | [diff] [blame] | 322 | bool GFX8Insts; |
Matt Arsenault | 2021f08 | 2017-02-18 19:12:26 +0000 | [diff] [blame] | 323 | bool GFX9Insts; |
Stanislav Mekhanoshin | cee607e | 2019-04-24 17:03:15 +0000 | [diff] [blame] | 324 | bool GFX10Insts; |
Stanislav Mekhanoshin | 7895c03 | 2019-04-05 18:24:34 +0000 | [diff] [blame] | 325 | bool GFX7GFX8GFX9Insts; |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 326 | bool SGPRInitBug; |
Matt Arsenault | 9d82ee7 | 2016-02-27 08:53:55 +0000 | [diff] [blame] | 327 | bool HasSMemRealTime; |
Dmitry Preobrazhensky | ff64aa5 | 2017-08-16 13:51:56 +0000 | [diff] [blame] | 328 | bool HasIntClamp; |
Matt Arsenault | 0084adc | 2018-04-30 19:08:16 +0000 | [diff] [blame] | 329 | bool HasFmaMixInsts; |
Matt Arsenault | cc88ce3 | 2016-10-12 18:00:51 +0000 | [diff] [blame] | 330 | bool HasMovrel; |
| 331 | bool HasVGPRIndexMode; |
Matt Arsenault | 7b64755 | 2016-10-28 21:55:15 +0000 | [diff] [blame] | 332 | bool HasScalarStores; |
Dmitry Preobrazhensky | 6bad04e | 2018-04-02 16:10:25 +0000 | [diff] [blame] | 333 | bool HasScalarAtomics; |
Sam Kolton | 3c4933f | 2017-06-22 06:26:41 +0000 | [diff] [blame] | 334 | bool HasSDWAOmod; |
| 335 | bool HasSDWAScalar; |
| 336 | bool HasSDWASdst; |
| 337 | bool HasSDWAMac; |
Sam Kolton | a179d25 | 2017-06-27 15:02:23 +0000 | [diff] [blame] | 338 | bool HasSDWAOutModsVOPC; |
Sam Kolton | 07dbde2 | 2017-01-20 10:01:25 +0000 | [diff] [blame] | 339 | bool HasDPP; |
Stanislav Mekhanoshin | 245b5ba | 2019-06-12 18:02:41 +0000 | [diff] [blame] | 340 | bool HasDPP8; |
Ryan Taylor | 1f334d0 | 2018-08-28 15:07:30 +0000 | [diff] [blame] | 341 | bool HasR128A16; |
Stanislav Mekhanoshin | cee607e | 2019-04-24 17:03:15 +0000 | [diff] [blame] | 342 | bool HasNSAEncoding; |
Matt Arsenault | 0084adc | 2018-04-30 19:08:16 +0000 | [diff] [blame] | 343 | bool HasDLInsts; |
Stanislav Mekhanoshin | 0e858b0 | 2019-02-09 00:34:21 +0000 | [diff] [blame] | 344 | bool HasDot1Insts; |
| 345 | bool HasDot2Insts; |
Stanislav Mekhanoshin | 22b2c3d | 2019-07-09 18:10:06 +0000 | [diff] [blame] | 346 | bool HasDot3Insts; |
| 347 | bool HasDot4Insts; |
Stanislav Mekhanoshin | c43e67b | 2019-06-14 00:33:31 +0000 | [diff] [blame] | 348 | bool HasDot5Insts; |
| 349 | bool HasDot6Insts; |
Stanislav Mekhanoshin | 22b2c3d | 2019-07-09 18:10:06 +0000 | [diff] [blame] | 350 | bool HasMAIInsts; |
| 351 | bool HasPkFmacF16Inst; |
| 352 | bool HasAtomicFaddInsts; |
Konstantin Zhuravlyov | 108927b | 2018-11-05 22:44:19 +0000 | [diff] [blame] | 353 | bool EnableSRAMECC; |
Matt Arsenault | f426ddb | 2019-04-03 01:58:57 +0000 | [diff] [blame] | 354 | bool DoesNotSupportSRAMECC; |
Stanislav Mekhanoshin | cee607e | 2019-04-24 17:03:15 +0000 | [diff] [blame] | 355 | bool HasNoSdstCMPX; |
| 356 | bool HasVscnt; |
| 357 | bool HasRegisterBanking; |
| 358 | bool HasVOP3Literal; |
| 359 | bool HasNoDataDepHazard; |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 360 | bool FlatAddressSpace; |
Matt Arsenault | acdc765 | 2017-05-10 21:19:05 +0000 | [diff] [blame] | 361 | bool FlatInstOffsets; |
| 362 | bool FlatGlobalInsts; |
| 363 | bool FlatScratchInsts; |
Stanislav Mekhanoshin | cee607e | 2019-04-24 17:03:15 +0000 | [diff] [blame] | 364 | bool ScalarFlatScratchInsts; |
Matt Arsenault | c37fe66 | 2017-07-20 17:42:47 +0000 | [diff] [blame] | 365 | bool AddNoCarryInsts; |
Changpeng Fang | 44dfa1d | 2018-01-12 21:12:19 +0000 | [diff] [blame] | 366 | bool HasUnpackedD16VMem; |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 367 | bool R600ALUInst; |
| 368 | bool CaymanISA; |
| 369 | bool CFALUBug; |
Stanislav Mekhanoshin | cee607e | 2019-04-24 17:03:15 +0000 | [diff] [blame] | 370 | bool LDSMisalignedBug; |
Stanislav Mekhanoshin | 8fe1245 | 2019-08-23 22:09:58 +0000 | [diff] [blame] | 371 | bool HasMFMAInlineLiteralBug; |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 372 | bool HasVertexCache; |
| 373 | short TexVTXClauseSize; |
Alexander Timofeev | 1800956 | 2016-12-08 17:28:47 +0000 | [diff] [blame] | 374 | bool ScalarizeGlobal; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 375 | |
Stanislav Mekhanoshin | cee607e | 2019-04-24 17:03:15 +0000 | [diff] [blame] | 376 | bool HasVcmpxPermlaneHazard; |
| 377 | bool HasVMEMtoScalarWriteHazard; |
| 378 | bool HasSMEMtoVectorWriteHazard; |
| 379 | bool HasInstFwdPrefetchBug; |
| 380 | bool HasVcmpxExecWARHazard; |
| 381 | bool HasLdsBranchVmemWARHazard; |
| 382 | bool HasNSAtoVMEMBug; |
Ryan Taylor | 9ab812d | 2019-06-26 17:34:57 +0000 | [diff] [blame] | 383 | bool HasOffset3fBug; |
Stanislav Mekhanoshin | cee607e | 2019-04-24 17:03:15 +0000 | [diff] [blame] | 384 | bool HasFlatSegmentOffsetBug; |
| 385 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 386 | // Dummy feature to use for assembler in tablegen. |
| 387 | bool FeatureDisable; |
| 388 | |
Matt Arsenault | 56684d4 | 2016-08-11 17:31:42 +0000 | [diff] [blame] | 389 | SelectionDAGTargetInfo TSInfo; |
Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 390 | private: |
Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 391 | SIInstrInfo InstrInfo; |
Tom Stellard | 752ddbd | 2018-07-11 22:15:15 +0000 | [diff] [blame] | 392 | SITargetLowering TLInfo; |
Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 393 | SIFrameLowering FrameLowering; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 394 | |
Matt Arsenault | 5c714cb | 2019-05-23 19:38:14 +0000 | [diff] [blame] | 395 | // See COMPUTE_TMPRING_SIZE.WAVESIZE, 13-bit field in units of 256-dword. |
| 396 | static const unsigned MaxWaveScratchSize = (256 * 4) * ((1 << 13) - 1); |
| 397 | |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 398 | public: |
Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 399 | GCNSubtarget(const Triple &TT, StringRef GPU, StringRef FS, |
| 400 | const GCNTargetMachine &TM); |
| 401 | ~GCNSubtarget() override; |
Eugene Zelenko | 2bc2f33 | 2016-12-09 22:06:55 +0000 | [diff] [blame] | 402 | |
Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 403 | GCNSubtarget &initializeSubtargetDependencies(const Triple &TT, |
Daniel Sanders | a73f1fd | 2015-06-10 12:11:26 +0000 | [diff] [blame] | 404 | StringRef GPU, StringRef FS); |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 405 | |
Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 406 | const SIInstrInfo *getInstrInfo() const override { |
| 407 | return &InstrInfo; |
| 408 | } |
Tom Stellard | 000c5af | 2016-04-14 19:09:28 +0000 | [diff] [blame] | 409 | |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 410 | const SIFrameLowering *getFrameLowering() const override { |
| 411 | return &FrameLowering; |
| 412 | } |
| 413 | |
Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 414 | const SITargetLowering *getTargetLowering() const override { |
| 415 | return &TLInfo; |
| 416 | } |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 417 | |
Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 418 | const SIRegisterInfo *getRegisterInfo() const override { |
| 419 | return &InstrInfo.getRegisterInfo(); |
| 420 | } |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 421 | |
| 422 | const CallLowering *getCallLowering() const override { |
| 423 | return CallLoweringInfo.get(); |
| 424 | } |
| 425 | |
Amara Emerson | e14c91b | 2019-08-13 06:26:59 +0000 | [diff] [blame] | 426 | InstructionSelector *getInstructionSelector() const override { |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 427 | return InstSelector.get(); |
| 428 | } |
| 429 | |
| 430 | const LegalizerInfo *getLegalizerInfo() const override { |
| 431 | return Legalizer.get(); |
| 432 | } |
| 433 | |
| 434 | const RegisterBankInfo *getRegBankInfo() const override { |
| 435 | return RegBankInfo.get(); |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 436 | } |
Matt Arsenault | d782d05 | 2014-06-27 17:57:00 +0000 | [diff] [blame] | 437 | |
Matt Arsenault | 56684d4 | 2016-08-11 17:31:42 +0000 | [diff] [blame] | 438 | // Nothing implemented, just prevent crashes on use. |
| 439 | const SelectionDAGTargetInfo *getSelectionDAGInfo() const override { |
| 440 | return &TSInfo; |
| 441 | } |
| 442 | |
Stanislav Mekhanoshin | 06d3b41 | 2018-09-17 16:04:32 +0000 | [diff] [blame] | 443 | const InstrItineraryData *getInstrItineraryData() const override { |
| 444 | return &InstrItins; |
| 445 | } |
| 446 | |
Craig Topper | ee7b0f3 | 2014-04-30 05:53:27 +0000 | [diff] [blame] | 447 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 448 | |
Matt Arsenault | d782d05 | 2014-06-27 17:57:00 +0000 | [diff] [blame] | 449 | Generation getGeneration() const { |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 450 | return (Generation)Gen; |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 451 | } |
| 452 | |
Matt Arsenault | 4eea3f3 | 2017-11-13 22:55:05 +0000 | [diff] [blame] | 453 | unsigned getWavefrontSizeLog2() const { |
| 454 | return Log2_32(WavefrontSize); |
| 455 | } |
| 456 | |
Matt Arsenault | 5c714cb | 2019-05-23 19:38:14 +0000 | [diff] [blame] | 457 | /// Return the number of high bits known to be zero fror a frame index. |
| 458 | unsigned getKnownHighZeroBitsForFrameIndex() const { |
| 459 | return countLeadingZeros(MaxWaveScratchSize) + getWavefrontSizeLog2(); |
| 460 | } |
| 461 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 462 | int getLDSBankCount() const { |
| 463 | return LDSBankCount; |
| 464 | } |
| 465 | |
| 466 | unsigned getMaxPrivateElementSize() const { |
| 467 | return MaxPrivateElementSize; |
| 468 | } |
| 469 | |
Stanislav Mekhanoshin | f2baae0 | 2019-05-02 03:47:23 +0000 | [diff] [blame] | 470 | unsigned getConstantBusLimit(unsigned Opcode) const; |
| 471 | |
Dmitry Preobrazhensky | ff64aa5 | 2017-08-16 13:51:56 +0000 | [diff] [blame] | 472 | bool hasIntClamp() const { |
| 473 | return HasIntClamp; |
| 474 | } |
| 475 | |
Jan Vesely | d1c9b61 | 2017-12-04 22:57:29 +0000 | [diff] [blame] | 476 | bool hasFP64() const { |
Matt Arsenault | d782d05 | 2014-06-27 17:57:00 +0000 | [diff] [blame] | 477 | return FP64; |
| 478 | } |
| 479 | |
Dmitry Preobrazhensky | e3271ae | 2018-02-05 12:45:43 +0000 | [diff] [blame] | 480 | bool hasMIMG_R128() const { |
| 481 | return MIMG_R128; |
| 482 | } |
| 483 | |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 484 | bool hasHWFP64() const { |
| 485 | return FP64; |
| 486 | } |
| 487 | |
Matt Arsenault | b035a57 | 2015-01-29 19:34:25 +0000 | [diff] [blame] | 488 | bool hasFastFMAF32() const { |
| 489 | return FastFMAF32; |
| 490 | } |
| 491 | |
Matt Arsenault | e83690c | 2016-01-18 21:13:50 +0000 | [diff] [blame] | 492 | bool hasHalfRate64Ops() const { |
| 493 | return HalfRate64Ops; |
| 494 | } |
| 495 | |
Matt Arsenault | 8870181 | 2016-06-09 23:42:48 +0000 | [diff] [blame] | 496 | bool hasAddr64() const { |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 497 | return (getGeneration() < AMDGPUSubtarget::VOLCANIC_ISLANDS); |
Matt Arsenault | 8870181 | 2016-06-09 23:42:48 +0000 | [diff] [blame] | 498 | } |
| 499 | |
Matt Arsenault | e4c2e9b | 2019-06-19 23:54:58 +0000 | [diff] [blame] | 500 | // Return true if the target only has the reverse operand versions of VALU |
| 501 | // shift instructions (e.g. v_lshrrev_b32, and no v_lshr_b32). |
| 502 | bool hasOnlyRevVALUShifts() const { |
| 503 | return getGeneration() >= VOLCANIC_ISLANDS; |
| 504 | } |
| 505 | |
Matt Arsenault | fae0298 | 2014-03-17 18:58:11 +0000 | [diff] [blame] | 506 | bool hasBFE() const { |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 507 | return true; |
Matt Arsenault | fae0298 | 2014-03-17 18:58:11 +0000 | [diff] [blame] | 508 | } |
| 509 | |
Matt Arsenault | 6e43965 | 2014-06-10 19:00:20 +0000 | [diff] [blame] | 510 | bool hasBFI() const { |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 511 | return true; |
Matt Arsenault | 6e43965 | 2014-06-10 19:00:20 +0000 | [diff] [blame] | 512 | } |
| 513 | |
Matt Arsenault | fae0298 | 2014-03-17 18:58:11 +0000 | [diff] [blame] | 514 | bool hasBFM() const { |
| 515 | return hasBFE(); |
| 516 | } |
| 517 | |
Matt Arsenault | 6042506 | 2014-06-10 19:18:28 +0000 | [diff] [blame] | 518 | bool hasBCNT(unsigned Size) const { |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 519 | return true; |
Tom Stellard | 50122a5 | 2014-04-07 19:45:41 +0000 | [diff] [blame] | 520 | } |
| 521 | |
Jan Vesely | 6ddb8dd | 2014-07-15 15:51:09 +0000 | [diff] [blame] | 522 | bool hasFFBL() const { |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 523 | return true; |
Jan Vesely | 6ddb8dd | 2014-07-15 15:51:09 +0000 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | bool hasFFBH() const { |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 527 | return true; |
Jan Vesely | 6ddb8dd | 2014-07-15 15:51:09 +0000 | [diff] [blame] | 528 | } |
| 529 | |
Matt Arsenault | 10268f9 | 2017-02-27 22:40:39 +0000 | [diff] [blame] | 530 | bool hasMed3_16() const { |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 531 | return getGeneration() >= AMDGPUSubtarget::GFX9; |
Matt Arsenault | 10268f9 | 2017-02-27 22:40:39 +0000 | [diff] [blame] | 532 | } |
| 533 | |
Matt Arsenault | ee324ff | 2017-05-17 19:25:06 +0000 | [diff] [blame] | 534 | bool hasMin3Max3_16() const { |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 535 | return getGeneration() >= AMDGPUSubtarget::GFX9; |
Matt Arsenault | d7e2303 | 2017-09-07 18:05:07 +0000 | [diff] [blame] | 536 | } |
| 537 | |
Matt Arsenault | 0084adc | 2018-04-30 19:08:16 +0000 | [diff] [blame] | 538 | bool hasFmaMixInsts() const { |
| 539 | return HasFmaMixInsts; |
| 540 | } |
| 541 | |
Jan Vesely | 808fff5 | 2015-04-30 17:15:56 +0000 | [diff] [blame] | 542 | bool hasCARRY() const { |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 543 | return true; |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 544 | } |
| 545 | |
Jan Vesely | 39aeab4 | 2017-12-04 23:07:28 +0000 | [diff] [blame] | 546 | bool hasFMA() const { |
| 547 | return FMA; |
| 548 | } |
| 549 | |
Stanislav Mekhanoshin | 79080ec | 2018-10-29 17:26:01 +0000 | [diff] [blame] | 550 | bool hasSwap() const { |
| 551 | return GFX9Insts; |
| 552 | } |
| 553 | |
Matt Arsenault | 182f924 | 2019-09-09 17:04:18 +0000 | [diff] [blame^] | 554 | bool hasScalarPackInsts() const { |
| 555 | return GFX9Insts; |
| 556 | } |
| 557 | |
Wei Ding | 205bfdb | 2017-02-10 02:15:29 +0000 | [diff] [blame] | 558 | TrapHandlerAbi getTrapHandlerAbi() const { |
| 559 | return isAmdHsaOS() ? TrapHandlerAbiHsa : TrapHandlerAbiNone; |
| 560 | } |
| 561 | |
Matt Arsenault | e4c2e9b | 2019-06-19 23:54:58 +0000 | [diff] [blame] | 562 | /// True if the offset field of DS instructions works as expected. On SI, the |
| 563 | /// offset uses a 16-bit adder and does not always wrap properly. |
| 564 | bool hasUsableDSOffset() const { |
| 565 | return getGeneration() >= SEA_ISLANDS; |
| 566 | } |
| 567 | |
Matt Arsenault | 706f930 | 2015-07-06 16:01:58 +0000 | [diff] [blame] | 568 | bool unsafeDSOffsetFoldingEnabled() const { |
| 569 | return EnableUnsafeDSOffsetFolding; |
| 570 | } |
| 571 | |
Matt Arsenault | e4c2e9b | 2019-06-19 23:54:58 +0000 | [diff] [blame] | 572 | /// Condition output from div_scale is usable. |
| 573 | bool hasUsableDivScaleConditionOutput() const { |
| 574 | return getGeneration() != SOUTHERN_ISLANDS; |
| 575 | } |
| 576 | |
| 577 | /// Extra wait hazard is needed in some cases before |
| 578 | /// s_cbranch_vccnz/s_cbranch_vccz. |
| 579 | bool hasReadVCCZBug() const { |
| 580 | return getGeneration() <= SEA_ISLANDS; |
| 581 | } |
| 582 | |
| 583 | /// A read of an SGPR by SMRD instruction requires 4 wait states when the SGPR |
| 584 | /// was written by a VALU instruction. |
| 585 | bool hasSMRDReadVALUDefHazard() const { |
| 586 | return getGeneration() == SOUTHERN_ISLANDS; |
| 587 | } |
| 588 | |
| 589 | /// A read of an SGPR by a VMEM instruction requires 5 wait states when the |
| 590 | /// SGPR was written by a VALU Instruction. |
| 591 | bool hasVMEMReadSGPRVALUDefHazard() const { |
| 592 | return getGeneration() >= VOLCANIC_ISLANDS; |
| 593 | } |
| 594 | |
| 595 | bool hasRFEHazards() const { |
| 596 | return getGeneration() >= VOLCANIC_ISLANDS; |
| 597 | } |
| 598 | |
| 599 | /// Number of hazard wait states for s_setreg_b32/s_setreg_imm32_b32. |
| 600 | unsigned getSetRegWaitStates() const { |
| 601 | return getGeneration() <= SEA_ISLANDS ? 1 : 2; |
| 602 | } |
| 603 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 604 | bool dumpCode() const { |
| 605 | return DumpCode; |
Matt Arsenault | d782d05 | 2014-06-27 17:57:00 +0000 | [diff] [blame] | 606 | } |
| 607 | |
Matt Arsenault | 8a028bf | 2016-05-16 21:19:59 +0000 | [diff] [blame] | 608 | /// Return the amount of LDS that can be used that will not restrict the |
| 609 | /// occupancy lower than WaveCount. |
Stanislav Mekhanoshin | 2b913b1 | 2017-02-01 22:59:50 +0000 | [diff] [blame] | 610 | unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount, |
| 611 | const Function &) const; |
Matt Arsenault | 8a028bf | 2016-05-16 21:19:59 +0000 | [diff] [blame] | 612 | |
Konstantin Zhuravlyov | f86e4b7 | 2016-11-13 07:01:11 +0000 | [diff] [blame] | 613 | bool hasFP16Denormals() const { |
Matt Arsenault | a6867fd | 2017-01-23 22:31:03 +0000 | [diff] [blame] | 614 | return FP64FP16Denormals; |
Konstantin Zhuravlyov | f86e4b7 | 2016-11-13 07:01:11 +0000 | [diff] [blame] | 615 | } |
Matt Arsenault | 8a028bf | 2016-05-16 21:19:59 +0000 | [diff] [blame] | 616 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 617 | bool hasFP64Denormals() const { |
Matt Arsenault | a6867fd | 2017-01-23 22:31:03 +0000 | [diff] [blame] | 618 | return FP64FP16Denormals; |
Matt Arsenault | 24ee078 | 2016-02-12 02:40:47 +0000 | [diff] [blame] | 619 | } |
| 620 | |
Stanislav Mekhanoshin | dc2890a | 2017-07-13 23:59:15 +0000 | [diff] [blame] | 621 | bool supportsMinMaxDenormModes() const { |
| 622 | return getGeneration() >= AMDGPUSubtarget::GFX9; |
| 623 | } |
| 624 | |
Austin Kerbow | a05c384 | 2019-08-06 02:16:11 +0000 | [diff] [blame] | 625 | /// \returns If target supports S_DENORM_MODE. |
| 626 | bool hasDenormModeInst() const { |
| 627 | return getGeneration() >= AMDGPUSubtarget::GFX10; |
| 628 | } |
| 629 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 630 | bool useFlatForGlobal() const { |
| 631 | return FlatForGlobal; |
Tom Stellard | ec87f84 | 2015-05-25 16:15:54 +0000 | [diff] [blame] | 632 | } |
| 633 | |
Farhana Aleen | a7cb311 | 2018-03-09 17:41:39 +0000 | [diff] [blame] | 634 | /// \returns If target supports ds_read/write_b128 and user enables generation |
| 635 | /// of ds_read/write_b128. |
Marek Olsak | a9a58fa | 2018-04-10 22:48:23 +0000 | [diff] [blame] | 636 | bool useDS128() const { |
| 637 | return CIInsts && EnableDS128; |
Farhana Aleen | a7cb311 | 2018-03-09 17:41:39 +0000 | [diff] [blame] | 638 | } |
| 639 | |
Matt Arsenault | e4c2e9b | 2019-06-19 23:54:58 +0000 | [diff] [blame] | 640 | /// Have v_trunc_f64, v_ceil_f64, v_rndne_f64 |
| 641 | bool haveRoundOpsF64() const { |
| 642 | return CIInsts; |
| 643 | } |
| 644 | |
Matt Arsenault | caf0ed4 | 2017-11-30 00:52:40 +0000 | [diff] [blame] | 645 | /// \returns If MUBUF instructions always perform range checking, even for |
| 646 | /// buffer resources used for private memory access. |
| 647 | bool privateMemoryResourceIsRangeChecked() const { |
| 648 | return getGeneration() < AMDGPUSubtarget::GFX9; |
| 649 | } |
| 650 | |
David Stuttard | f77079f | 2019-01-14 11:55:24 +0000 | [diff] [blame] | 651 | /// \returns If target requires PRT Struct NULL support (zero result registers |
| 652 | /// for sparse texture support). |
| 653 | bool usePRTStrictNull() const { |
| 654 | return EnablePRTStrictNull; |
| 655 | } |
| 656 | |
Konstantin Zhuravlyov | be6c0ca | 2017-06-02 17:40:26 +0000 | [diff] [blame] | 657 | bool hasAutoWaitcntBeforeBarrier() const { |
| 658 | return AutoWaitcntBeforeBarrier; |
| 659 | } |
| 660 | |
Konstantin Zhuravlyov | eda425e | 2017-10-14 15:59:07 +0000 | [diff] [blame] | 661 | bool hasCodeObjectV3() const { |
Konstantin Zhuravlyov | a25e052 | 2018-11-15 02:32:43 +0000 | [diff] [blame] | 662 | // FIXME: Need to add code object v3 support for mesa and pal. |
| 663 | return isAmdHsaOS() ? CodeObjectV3 : false; |
Konstantin Zhuravlyov | eda425e | 2017-10-14 15:59:07 +0000 | [diff] [blame] | 664 | } |
| 665 | |
Matt Arsenault | 7f681ac | 2016-07-01 23:03:44 +0000 | [diff] [blame] | 666 | bool hasUnalignedBufferAccess() const { |
| 667 | return UnalignedBufferAccess; |
| 668 | } |
| 669 | |
Tom Stellard | 64a9d08 | 2016-10-14 18:10:39 +0000 | [diff] [blame] | 670 | bool hasUnalignedScratchAccess() const { |
| 671 | return UnalignedScratchAccess; |
| 672 | } |
| 673 | |
Matt Arsenault | e823d92 | 2017-02-18 18:29:53 +0000 | [diff] [blame] | 674 | bool hasApertureRegs() const { |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 675 | return HasApertureRegs; |
Matt Arsenault | e823d92 | 2017-02-18 18:29:53 +0000 | [diff] [blame] | 676 | } |
| 677 | |
Wei Ding | 205bfdb | 2017-02-10 02:15:29 +0000 | [diff] [blame] | 678 | bool isTrapHandlerEnabled() const { |
| 679 | return TrapHandler; |
| 680 | } |
| 681 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 682 | bool isXNACKEnabled() const { |
| 683 | return EnableXNACK; |
| 684 | } |
Tom Stellard | b8fd6ef | 2014-12-02 22:00:07 +0000 | [diff] [blame] | 685 | |
Stanislav Mekhanoshin | cee607e | 2019-04-24 17:03:15 +0000 | [diff] [blame] | 686 | bool isCuModeEnabled() const { |
| 687 | return EnableCuMode; |
| 688 | } |
| 689 | |
Matt Arsenault | b6491cc | 2017-01-31 01:20:54 +0000 | [diff] [blame] | 690 | bool hasFlatAddressSpace() const { |
| 691 | return FlatAddressSpace; |
| 692 | } |
| 693 | |
Matt Arsenault | e4c2e9b | 2019-06-19 23:54:58 +0000 | [diff] [blame] | 694 | bool hasFlatScrRegister() const { |
| 695 | return hasFlatAddressSpace(); |
| 696 | } |
| 697 | |
Matt Arsenault | acdc765 | 2017-05-10 21:19:05 +0000 | [diff] [blame] | 698 | bool hasFlatInstOffsets() const { |
| 699 | return FlatInstOffsets; |
| 700 | } |
| 701 | |
| 702 | bool hasFlatGlobalInsts() const { |
| 703 | return FlatGlobalInsts; |
| 704 | } |
| 705 | |
| 706 | bool hasFlatScratchInsts() const { |
| 707 | return FlatScratchInsts; |
| 708 | } |
| 709 | |
Stanislav Mekhanoshin | cee607e | 2019-04-24 17:03:15 +0000 | [diff] [blame] | 710 | bool hasScalarFlatScratchInsts() const { |
| 711 | return ScalarFlatScratchInsts; |
| 712 | } |
| 713 | |
| 714 | bool hasFlatSegmentOffsetBug() const { |
| 715 | return HasFlatSegmentOffsetBug; |
| 716 | } |
| 717 | |
Mark Searles | f0b93f1 | 2018-06-04 16:51:59 +0000 | [diff] [blame] | 718 | bool hasFlatLgkmVMemCountInOrder() const { |
| 719 | return getGeneration() > GFX9; |
| 720 | } |
| 721 | |
Matt Arsenault | ed6e8f0 | 2017-09-01 18:36:06 +0000 | [diff] [blame] | 722 | bool hasD16LoadStore() const { |
| 723 | return getGeneration() >= GFX9; |
| 724 | } |
| 725 | |
Matt Arsenault | e8c03a2 | 2019-03-08 20:58:11 +0000 | [diff] [blame] | 726 | bool d16PreservesUnusedBits() const { |
| 727 | return hasD16LoadStore() && !isSRAMECCEnabled(); |
| 728 | } |
| 729 | |
Matt Arsenault | e4c2e9b | 2019-06-19 23:54:58 +0000 | [diff] [blame] | 730 | bool hasD16Images() const { |
| 731 | return getGeneration() >= VOLCANIC_ISLANDS; |
| 732 | } |
| 733 | |
Matt Arsenault | 3f71c0e | 2017-11-29 00:55:57 +0000 | [diff] [blame] | 734 | /// Return if most LDS instructions have an m0 use that require m0 to be |
| 735 | /// iniitalized. |
| 736 | bool ldsRequiresM0Init() const { |
| 737 | return getGeneration() < GFX9; |
| 738 | } |
| 739 | |
Matt Arsenault | 8ad1dec | 2019-06-20 20:54:32 +0000 | [diff] [blame] | 740 | // True if the hardware rewinds and replays GWS operations if a wave is |
| 741 | // preempted. |
| 742 | // |
| 743 | // If this is false, a GWS operation requires testing if a nack set the |
| 744 | // MEM_VIOL bit, and repeating if so. |
| 745 | bool hasGWSAutoReplay() const { |
| 746 | return getGeneration() >= GFX9; |
| 747 | } |
| 748 | |
Matt Arsenault | 740322f | 2019-06-20 21:11:42 +0000 | [diff] [blame] | 749 | /// \returns if target has ds_gws_sema_release_all instruction. |
| 750 | bool hasGWSSemaReleaseAll() const { |
| 751 | return CIInsts; |
| 752 | } |
| 753 | |
Matt Arsenault | c37fe66 | 2017-07-20 17:42:47 +0000 | [diff] [blame] | 754 | bool hasAddNoCarry() const { |
| 755 | return AddNoCarryInsts; |
| 756 | } |
| 757 | |
Changpeng Fang | 44dfa1d | 2018-01-12 21:12:19 +0000 | [diff] [blame] | 758 | bool hasUnpackedD16VMem() const { |
| 759 | return HasUnpackedD16VMem; |
| 760 | } |
| 761 | |
Tom Stellard | 2f3f985 | 2017-01-25 01:25:13 +0000 | [diff] [blame] | 762 | // Covers VS/PS/CS graphics shaders |
Matt Arsenault | ceafc55 | 2018-05-29 17:42:50 +0000 | [diff] [blame] | 763 | bool isMesaGfxShader(const Function &F) const { |
| 764 | return isMesa3DOS() && AMDGPU::isShader(F.getCallingConv()); |
Tom Stellard | 2f3f985 | 2017-01-25 01:25:13 +0000 | [diff] [blame] | 765 | } |
| 766 | |
Matt Arsenault | 4f6318f | 2017-11-06 17:04:37 +0000 | [diff] [blame] | 767 | bool hasMad64_32() const { |
| 768 | return getGeneration() >= SEA_ISLANDS; |
| 769 | } |
| 770 | |
Sam Kolton | 3c4933f | 2017-06-22 06:26:41 +0000 | [diff] [blame] | 771 | bool hasSDWAOmod() const { |
| 772 | return HasSDWAOmod; |
| 773 | } |
| 774 | |
| 775 | bool hasSDWAScalar() const { |
| 776 | return HasSDWAScalar; |
| 777 | } |
| 778 | |
| 779 | bool hasSDWASdst() const { |
| 780 | return HasSDWASdst; |
| 781 | } |
| 782 | |
| 783 | bool hasSDWAMac() const { |
| 784 | return HasSDWAMac; |
| 785 | } |
| 786 | |
Sam Kolton | a179d25 | 2017-06-27 15:02:23 +0000 | [diff] [blame] | 787 | bool hasSDWAOutModsVOPC() const { |
| 788 | return HasSDWAOutModsVOPC; |
Sam Kolton | 3c4933f | 2017-06-22 06:26:41 +0000 | [diff] [blame] | 789 | } |
| 790 | |
Matt Arsenault | 0084adc | 2018-04-30 19:08:16 +0000 | [diff] [blame] | 791 | bool hasDLInsts() const { |
| 792 | return HasDLInsts; |
| 793 | } |
| 794 | |
Stanislav Mekhanoshin | 0e858b0 | 2019-02-09 00:34:21 +0000 | [diff] [blame] | 795 | bool hasDot1Insts() const { |
| 796 | return HasDot1Insts; |
| 797 | } |
| 798 | |
| 799 | bool hasDot2Insts() const { |
| 800 | return HasDot2Insts; |
Stanislav Mekhanoshin | d3757d3 | 2019-01-10 03:25:20 +0000 | [diff] [blame] | 801 | } |
| 802 | |
Stanislav Mekhanoshin | 22b2c3d | 2019-07-09 18:10:06 +0000 | [diff] [blame] | 803 | bool hasDot3Insts() const { |
| 804 | return HasDot3Insts; |
| 805 | } |
| 806 | |
| 807 | bool hasDot4Insts() const { |
| 808 | return HasDot4Insts; |
| 809 | } |
| 810 | |
Stanislav Mekhanoshin | c43e67b | 2019-06-14 00:33:31 +0000 | [diff] [blame] | 811 | bool hasDot5Insts() const { |
| 812 | return HasDot5Insts; |
| 813 | } |
| 814 | |
| 815 | bool hasDot6Insts() const { |
| 816 | return HasDot6Insts; |
| 817 | } |
| 818 | |
Stanislav Mekhanoshin | 22b2c3d | 2019-07-09 18:10:06 +0000 | [diff] [blame] | 819 | bool hasMAIInsts() const { |
| 820 | return HasMAIInsts; |
| 821 | } |
| 822 | |
| 823 | bool hasPkFmacF16Inst() const { |
| 824 | return HasPkFmacF16Inst; |
| 825 | } |
| 826 | |
| 827 | bool hasAtomicFaddInsts() const { |
| 828 | return HasAtomicFaddInsts; |
| 829 | } |
| 830 | |
Konstantin Zhuravlyov | 108927b | 2018-11-05 22:44:19 +0000 | [diff] [blame] | 831 | bool isSRAMECCEnabled() const { |
| 832 | return EnableSRAMECC; |
Konstantin Zhuravlyov | c2c2eb7 | 2018-05-04 20:06:57 +0000 | [diff] [blame] | 833 | } |
| 834 | |
Stanislav Mekhanoshin | cee607e | 2019-04-24 17:03:15 +0000 | [diff] [blame] | 835 | bool hasNoSdstCMPX() const { |
| 836 | return HasNoSdstCMPX; |
| 837 | } |
| 838 | |
| 839 | bool hasVscnt() const { |
| 840 | return HasVscnt; |
| 841 | } |
| 842 | |
| 843 | bool hasRegisterBanking() const { |
| 844 | return HasRegisterBanking; |
| 845 | } |
| 846 | |
| 847 | bool hasVOP3Literal() const { |
| 848 | return HasVOP3Literal; |
| 849 | } |
| 850 | |
| 851 | bool hasNoDataDepHazard() const { |
| 852 | return HasNoDataDepHazard; |
| 853 | } |
| 854 | |
| 855 | bool vmemWriteNeedsExpWaitcnt() const { |
| 856 | return getGeneration() < SEA_ISLANDS; |
| 857 | } |
| 858 | |
Matt Arsenault | 869fec2 | 2017-04-17 19:48:24 +0000 | [diff] [blame] | 859 | // Scratch is allocated in 256 dword per wave blocks for the entire |
| 860 | // wavefront. When viewed from the perspecive of an arbitrary workitem, this |
| 861 | // is 4-byte aligned. |
Matt Arsenault | ffb132e | 2018-03-29 20:22:04 +0000 | [diff] [blame] | 862 | // |
| 863 | // Only 4-byte alignment is really needed to access anything. Transformations |
| 864 | // on the pointer value itself may rely on the alignment / known low bits of |
| 865 | // the pointer. Set this to something above the minimum to avoid needing |
| 866 | // dynamic realignment in common cases. |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 867 | unsigned getStackAlignment() const { |
Matt Arsenault | ffb132e | 2018-03-29 20:22:04 +0000 | [diff] [blame] | 868 | return 16; |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 869 | } |
Tom Stellard | 347ac79 | 2015-06-26 21:15:07 +0000 | [diff] [blame] | 870 | |
Craig Topper | 5656db4 | 2014-04-29 07:57:24 +0000 | [diff] [blame] | 871 | bool enableMachineScheduler() const override { |
Tom Stellard | 83f0bce | 2015-01-29 16:55:25 +0000 | [diff] [blame] | 872 | return true; |
Andrew Trick | 978674b | 2013-09-20 05:14:41 +0000 | [diff] [blame] | 873 | } |
| 874 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 875 | bool enableSubRegLiveness() const override { |
| 876 | return true; |
| 877 | } |
Konstantin Zhuravlyov | 1d65026 | 2016-09-06 20:22:28 +0000 | [diff] [blame] | 878 | |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 879 | void setScalarizeGlobalBehavior(bool b) { ScalarizeGlobal = b; } |
| 880 | bool getScalarizeGlobalBehavior() const { return ScalarizeGlobal; } |
Konstantin Zhuravlyov | 9f89ede | 2017-02-08 14:05:23 +0000 | [diff] [blame] | 881 | |
Konstantin Zhuravlyov | 1d65026 | 2016-09-06 20:22:28 +0000 | [diff] [blame] | 882 | /// \returns Number of execution units per compute unit supported by the |
| 883 | /// subtarget. |
| 884 | unsigned getEUsPerCU() const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 885 | return AMDGPU::IsaInfo::getEUsPerCU(this); |
Konstantin Zhuravlyov | 1d65026 | 2016-09-06 20:22:28 +0000 | [diff] [blame] | 886 | } |
| 887 | |
| 888 | /// \returns Maximum number of waves per compute unit supported by the |
| 889 | /// subtarget without any kind of limitation. |
| 890 | unsigned getMaxWavesPerCU() const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 891 | return AMDGPU::IsaInfo::getMaxWavesPerCU(this); |
Konstantin Zhuravlyov | 1d65026 | 2016-09-06 20:22:28 +0000 | [diff] [blame] | 892 | } |
| 893 | |
| 894 | /// \returns Maximum number of waves per compute unit supported by the |
Konstantin Zhuravlyov | 9f89ede | 2017-02-08 14:05:23 +0000 | [diff] [blame] | 895 | /// subtarget and limited by given \p FlatWorkGroupSize. |
Konstantin Zhuravlyov | 1d65026 | 2016-09-06 20:22:28 +0000 | [diff] [blame] | 896 | unsigned getMaxWavesPerCU(unsigned FlatWorkGroupSize) const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 897 | return AMDGPU::IsaInfo::getMaxWavesPerCU(this, FlatWorkGroupSize); |
Konstantin Zhuravlyov | 1d65026 | 2016-09-06 20:22:28 +0000 | [diff] [blame] | 898 | } |
| 899 | |
Konstantin Zhuravlyov | 9f89ede | 2017-02-08 14:05:23 +0000 | [diff] [blame] | 900 | /// \returns Number of waves per work group supported by the subtarget and |
| 901 | /// limited by given \p FlatWorkGroupSize. |
Konstantin Zhuravlyov | 1d65026 | 2016-09-06 20:22:28 +0000 | [diff] [blame] | 902 | unsigned getWavesPerWorkGroup(unsigned FlatWorkGroupSize) const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 903 | return AMDGPU::IsaInfo::getWavesPerWorkGroup(this, FlatWorkGroupSize); |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 904 | } |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 905 | |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 906 | // static wrappers |
| 907 | static bool hasHalfRate64Ops(const TargetSubtargetInfo &STI); |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 908 | |
Matt Arsenault | 9f5e0ef | 2017-01-25 04:25:02 +0000 | [diff] [blame] | 909 | // XXX - Why is this here if it isn't in the default pass set? |
| 910 | bool enableEarlyIfConversion() const override { |
| 911 | return true; |
| 912 | } |
| 913 | |
Tom Stellard | 83f0bce | 2015-01-29 16:55:25 +0000 | [diff] [blame] | 914 | void overrideSchedPolicy(MachineSchedPolicy &Policy, |
Tom Stellard | 83f0bce | 2015-01-29 16:55:25 +0000 | [diff] [blame] | 915 | unsigned NumRegionInstrs) const override; |
| 916 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 917 | unsigned getMaxNumUserSGPRs() const { |
| 918 | return 16; |
| 919 | } |
| 920 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 921 | bool hasSMemRealTime() const { |
| 922 | return HasSMemRealTime; |
| 923 | } |
| 924 | |
Matt Arsenault | cc88ce3 | 2016-10-12 18:00:51 +0000 | [diff] [blame] | 925 | bool hasMovrel() const { |
| 926 | return HasMovrel; |
| 927 | } |
| 928 | |
| 929 | bool hasVGPRIndexMode() const { |
| 930 | return HasVGPRIndexMode; |
| 931 | } |
| 932 | |
Marek Olsak | e22fdb9 | 2017-03-21 17:00:32 +0000 | [diff] [blame] | 933 | bool useVGPRIndexMode(bool UserEnable) const { |
| 934 | return !hasMovrel() || (UserEnable && hasVGPRIndexMode()); |
| 935 | } |
| 936 | |
Matt Arsenault | 7b1dc2c | 2016-09-17 02:02:19 +0000 | [diff] [blame] | 937 | bool hasScalarCompareEq64() const { |
| 938 | return getGeneration() >= VOLCANIC_ISLANDS; |
| 939 | } |
| 940 | |
Matt Arsenault | 7b64755 | 2016-10-28 21:55:15 +0000 | [diff] [blame] | 941 | bool hasScalarStores() const { |
| 942 | return HasScalarStores; |
| 943 | } |
| 944 | |
Dmitry Preobrazhensky | 6bad04e | 2018-04-02 16:10:25 +0000 | [diff] [blame] | 945 | bool hasScalarAtomics() const { |
| 946 | return HasScalarAtomics; |
| 947 | } |
| 948 | |
Matt Arsenault | a5840c3 | 2019-01-22 18:36:06 +0000 | [diff] [blame] | 949 | bool hasLDSFPAtomics() const { |
Stanislav Mekhanoshin | 7895c03 | 2019-04-05 18:24:34 +0000 | [diff] [blame] | 950 | return GFX8Insts; |
Matt Arsenault | a5840c3 | 2019-01-22 18:36:06 +0000 | [diff] [blame] | 951 | } |
Matt Arsenault | c88ba36 | 2016-10-29 04:05:06 +0000 | [diff] [blame] | 952 | |
Sam Kolton | 07dbde2 | 2017-01-20 10:01:25 +0000 | [diff] [blame] | 953 | bool hasDPP() const { |
| 954 | return HasDPP; |
| 955 | } |
| 956 | |
Jay Foad | eac2386 | 2019-08-23 10:07:43 +0000 | [diff] [blame] | 957 | bool hasDPPBroadcasts() const { |
| 958 | return HasDPP && getGeneration() < GFX10; |
| 959 | } |
| 960 | |
| 961 | bool hasDPPWavefrontShifts() const { |
| 962 | return HasDPP && getGeneration() < GFX10; |
| 963 | } |
| 964 | |
Stanislav Mekhanoshin | 245b5ba | 2019-06-12 18:02:41 +0000 | [diff] [blame] | 965 | bool hasDPP8() const { |
| 966 | return HasDPP8; |
| 967 | } |
| 968 | |
Ryan Taylor | 1f334d0 | 2018-08-28 15:07:30 +0000 | [diff] [blame] | 969 | bool hasR128A16() const { |
| 970 | return HasR128A16; |
| 971 | } |
| 972 | |
Ryan Taylor | 9ab812d | 2019-06-26 17:34:57 +0000 | [diff] [blame] | 973 | bool hasOffset3fBug() const { |
| 974 | return HasOffset3fBug; |
| 975 | } |
| 976 | |
Stanislav Mekhanoshin | cee607e | 2019-04-24 17:03:15 +0000 | [diff] [blame] | 977 | bool hasNSAEncoding() const { |
| 978 | return HasNSAEncoding; |
| 979 | } |
| 980 | |
| 981 | bool hasMadF16() const; |
| 982 | |
Tom Stellard | de008d3 | 2016-01-21 04:28:34 +0000 | [diff] [blame] | 983 | bool enableSIScheduler() const { |
| 984 | return EnableSIScheduler; |
| 985 | } |
| 986 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 987 | bool loadStoreOptEnabled() const { |
| 988 | return EnableLoadStoreOpt; |
Nicolai Haehnle | 5b50497 | 2016-01-04 23:35:53 +0000 | [diff] [blame] | 989 | } |
| 990 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame] | 991 | bool hasSGPRInitBug() const { |
| 992 | return SGPRInitBug; |
Matt Arsenault | 41003af | 2015-11-30 21:16:07 +0000 | [diff] [blame] | 993 | } |
Tom Stellard | 0d23ebe | 2016-08-29 19:42:52 +0000 | [diff] [blame] | 994 | |
Stanislav Mekhanoshin | 8fe1245 | 2019-08-23 22:09:58 +0000 | [diff] [blame] | 995 | bool hasMFMAInlineLiteralBug() const { |
| 996 | return HasMFMAInlineLiteralBug; |
| 997 | } |
| 998 | |
Tom Stellard | b133fbb | 2016-10-27 23:05:31 +0000 | [diff] [blame] | 999 | bool has12DWordStoreHazard() const { |
| 1000 | return getGeneration() != AMDGPUSubtarget::SOUTHERN_ISLANDS; |
| 1001 | } |
| 1002 | |
Neil Henning | e85d45a | 2019-01-10 16:21:08 +0000 | [diff] [blame] | 1003 | // \returns true if the subtarget supports DWORDX3 load/store instructions. |
| 1004 | bool hasDwordx3LoadStores() const { |
| 1005 | return CIInsts; |
| 1006 | } |
| 1007 | |
Matt Arsenault | e823d92 | 2017-02-18 18:29:53 +0000 | [diff] [blame] | 1008 | bool hasSMovFedHazard() const { |
Stanislav Mekhanoshin | 7895c03 | 2019-04-05 18:24:34 +0000 | [diff] [blame] | 1009 | return getGeneration() == AMDGPUSubtarget::GFX9; |
Matt Arsenault | e823d92 | 2017-02-18 18:29:53 +0000 | [diff] [blame] | 1010 | } |
| 1011 | |
Matt Arsenault | a41351e | 2017-11-17 21:35:32 +0000 | [diff] [blame] | 1012 | bool hasReadM0MovRelInterpHazard() const { |
Stanislav Mekhanoshin | 7895c03 | 2019-04-05 18:24:34 +0000 | [diff] [blame] | 1013 | return getGeneration() == AMDGPUSubtarget::GFX9; |
Matt Arsenault | e823d92 | 2017-02-18 18:29:53 +0000 | [diff] [blame] | 1014 | } |
| 1015 | |
Matt Arsenault | a41351e | 2017-11-17 21:35:32 +0000 | [diff] [blame] | 1016 | bool hasReadM0SendMsgHazard() const { |
Stanislav Mekhanoshin | 7895c03 | 2019-04-05 18:24:34 +0000 | [diff] [blame] | 1017 | return getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS && |
| 1018 | getGeneration() <= AMDGPUSubtarget::GFX9; |
Matt Arsenault | a41351e | 2017-11-17 21:35:32 +0000 | [diff] [blame] | 1019 | } |
| 1020 | |
Stanislav Mekhanoshin | cee607e | 2019-04-24 17:03:15 +0000 | [diff] [blame] | 1021 | bool hasVcmpxPermlaneHazard() const { |
| 1022 | return HasVcmpxPermlaneHazard; |
| 1023 | } |
| 1024 | |
| 1025 | bool hasVMEMtoScalarWriteHazard() const { |
| 1026 | return HasVMEMtoScalarWriteHazard; |
| 1027 | } |
| 1028 | |
| 1029 | bool hasSMEMtoVectorWriteHazard() const { |
| 1030 | return HasSMEMtoVectorWriteHazard; |
| 1031 | } |
| 1032 | |
| 1033 | bool hasLDSMisalignedBug() const { |
| 1034 | return LDSMisalignedBug && !EnableCuMode; |
| 1035 | } |
| 1036 | |
| 1037 | bool hasInstFwdPrefetchBug() const { |
| 1038 | return HasInstFwdPrefetchBug; |
| 1039 | } |
| 1040 | |
| 1041 | bool hasVcmpxExecWARHazard() const { |
| 1042 | return HasVcmpxExecWARHazard; |
| 1043 | } |
| 1044 | |
| 1045 | bool hasLdsBranchVmemWARHazard() const { |
| 1046 | return HasLdsBranchVmemWARHazard; |
| 1047 | } |
| 1048 | |
| 1049 | bool hasNSAtoVMEMBug() const { |
| 1050 | return HasNSAtoVMEMBug; |
| 1051 | } |
| 1052 | |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 1053 | /// Return the maximum number of waves per SIMD for kernels using \p SGPRs |
| 1054 | /// SGPRs |
Tom Stellard | 0d23ebe | 2016-08-29 19:42:52 +0000 | [diff] [blame] | 1055 | unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const; |
| 1056 | |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 1057 | /// Return the maximum number of waves per SIMD for kernels using \p VGPRs |
| 1058 | /// VGPRs |
Tom Stellard | 0d23ebe | 2016-08-29 19:42:52 +0000 | [diff] [blame] | 1059 | unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const; |
Konstantin Zhuravlyov | d7bdf24 | 2016-09-30 16:50:36 +0000 | [diff] [blame] | 1060 | |
Stanislav Mekhanoshin | 2594fa8 | 2019-07-31 01:07:10 +0000 | [diff] [blame] | 1061 | /// Return occupancy for the given function. Used LDS and a number of |
| 1062 | /// registers if provided. |
| 1063 | /// Note, occupancy can be affected by the scratch allocation as well, but |
| 1064 | /// we do not have enough information to compute it. |
| 1065 | unsigned computeOccupancy(const MachineFunction &MF, unsigned LDSSize = 0, |
| 1066 | unsigned NumSGPRs = 0, unsigned NumVGPRs = 0) const; |
| 1067 | |
Matt Arsenault | e823d92 | 2017-02-18 18:29:53 +0000 | [diff] [blame] | 1068 | /// \returns true if the flat_scratch register should be initialized with the |
| 1069 | /// pointer to the wave's scratch memory rather than a size and offset. |
| 1070 | bool flatScratchIsPointer() const { |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 1071 | return getGeneration() >= AMDGPUSubtarget::GFX9; |
Konstantin Zhuravlyov | d7bdf24 | 2016-09-30 16:50:36 +0000 | [diff] [blame] | 1072 | } |
Matt Arsenault | 4eae301 | 2016-10-28 20:31:47 +0000 | [diff] [blame] | 1073 | |
Tim Renouf | 832f90f | 2018-02-26 14:46:43 +0000 | [diff] [blame] | 1074 | /// \returns true if the machine has merged shaders in which s0-s7 are |
| 1075 | /// reserved by the hardware and user SGPRs start at s8 |
| 1076 | bool hasMergedShaders() const { |
| 1077 | return getGeneration() >= GFX9; |
| 1078 | } |
| 1079 | |
Konstantin Zhuravlyov | e03b1d7 | 2017-02-08 13:02:33 +0000 | [diff] [blame] | 1080 | /// \returns SGPR allocation granularity supported by the subtarget. |
| 1081 | unsigned getSGPRAllocGranule() const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 1082 | return AMDGPU::IsaInfo::getSGPRAllocGranule(this); |
Konstantin Zhuravlyov | e22fbcb | 2017-02-08 13:18:40 +0000 | [diff] [blame] | 1083 | } |
| 1084 | |
| 1085 | /// \returns SGPR encoding granularity supported by the subtarget. |
| 1086 | unsigned getSGPREncodingGranule() const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 1087 | return AMDGPU::IsaInfo::getSGPREncodingGranule(this); |
Konstantin Zhuravlyov | e03b1d7 | 2017-02-08 13:02:33 +0000 | [diff] [blame] | 1088 | } |
| 1089 | |
| 1090 | /// \returns Total number of SGPRs supported by the subtarget. |
| 1091 | unsigned getTotalNumSGPRs() const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 1092 | return AMDGPU::IsaInfo::getTotalNumSGPRs(this); |
Konstantin Zhuravlyov | e03b1d7 | 2017-02-08 13:02:33 +0000 | [diff] [blame] | 1093 | } |
| 1094 | |
| 1095 | /// \returns Addressable number of SGPRs supported by the subtarget. |
| 1096 | unsigned getAddressableNumSGPRs() const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 1097 | return AMDGPU::IsaInfo::getAddressableNumSGPRs(this); |
Konstantin Zhuravlyov | e03b1d7 | 2017-02-08 13:02:33 +0000 | [diff] [blame] | 1098 | } |
| 1099 | |
| 1100 | /// \returns Minimum number of SGPRs that meets the given number of waves per |
| 1101 | /// execution unit requirement supported by the subtarget. |
Konstantin Zhuravlyov | 9f89ede | 2017-02-08 14:05:23 +0000 | [diff] [blame] | 1102 | unsigned getMinNumSGPRs(unsigned WavesPerEU) const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 1103 | return AMDGPU::IsaInfo::getMinNumSGPRs(this, WavesPerEU); |
Konstantin Zhuravlyov | 9f89ede | 2017-02-08 14:05:23 +0000 | [diff] [blame] | 1104 | } |
Konstantin Zhuravlyov | e03b1d7 | 2017-02-08 13:02:33 +0000 | [diff] [blame] | 1105 | |
| 1106 | /// \returns Maximum number of SGPRs that meets the given number of waves per |
| 1107 | /// execution unit requirement supported by the subtarget. |
Konstantin Zhuravlyov | 9f89ede | 2017-02-08 14:05:23 +0000 | [diff] [blame] | 1108 | unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 1109 | return AMDGPU::IsaInfo::getMaxNumSGPRs(this, WavesPerEU, Addressable); |
Konstantin Zhuravlyov | 9f89ede | 2017-02-08 14:05:23 +0000 | [diff] [blame] | 1110 | } |
Konstantin Zhuravlyov | e03b1d7 | 2017-02-08 13:02:33 +0000 | [diff] [blame] | 1111 | |
| 1112 | /// \returns Reserved number of SGPRs for given function \p MF. |
| 1113 | unsigned getReservedNumSGPRs(const MachineFunction &MF) const; |
| 1114 | |
| 1115 | /// \returns Maximum number of SGPRs that meets number of waves per execution |
| 1116 | /// unit requirement for function \p MF, or number of SGPRs explicitly |
| 1117 | /// requested using "amdgpu-num-sgpr" attribute attached to function \p MF. |
| 1118 | /// |
| 1119 | /// \returns Value that meets number of waves per execution unit requirement |
| 1120 | /// if explicitly requested value cannot be converted to integer, violates |
| 1121 | /// subtarget's specifications, or does not meet number of waves per execution |
| 1122 | /// unit requirement. |
| 1123 | unsigned getMaxNumSGPRs(const MachineFunction &MF) const; |
| 1124 | |
| 1125 | /// \returns VGPR allocation granularity supported by the subtarget. |
| 1126 | unsigned getVGPRAllocGranule() const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 1127 | return AMDGPU::IsaInfo::getVGPRAllocGranule(this); |
Konstantin Zhuravlyov | e03b1d7 | 2017-02-08 13:02:33 +0000 | [diff] [blame] | 1128 | } |
| 1129 | |
Konstantin Zhuravlyov | e22fbcb | 2017-02-08 13:18:40 +0000 | [diff] [blame] | 1130 | /// \returns VGPR encoding granularity supported by the subtarget. |
| 1131 | unsigned getVGPREncodingGranule() const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 1132 | return AMDGPU::IsaInfo::getVGPREncodingGranule(this); |
Konstantin Zhuravlyov | e22fbcb | 2017-02-08 13:18:40 +0000 | [diff] [blame] | 1133 | } |
| 1134 | |
Konstantin Zhuravlyov | e03b1d7 | 2017-02-08 13:02:33 +0000 | [diff] [blame] | 1135 | /// \returns Total number of VGPRs supported by the subtarget. |
| 1136 | unsigned getTotalNumVGPRs() const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 1137 | return AMDGPU::IsaInfo::getTotalNumVGPRs(this); |
Konstantin Zhuravlyov | e03b1d7 | 2017-02-08 13:02:33 +0000 | [diff] [blame] | 1138 | } |
| 1139 | |
| 1140 | /// \returns Addressable number of VGPRs supported by the subtarget. |
| 1141 | unsigned getAddressableNumVGPRs() const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 1142 | return AMDGPU::IsaInfo::getAddressableNumVGPRs(this); |
Konstantin Zhuravlyov | e03b1d7 | 2017-02-08 13:02:33 +0000 | [diff] [blame] | 1143 | } |
| 1144 | |
| 1145 | /// \returns Minimum number of VGPRs that meets given number of waves per |
| 1146 | /// execution unit requirement supported by the subtarget. |
Konstantin Zhuravlyov | 9f89ede | 2017-02-08 14:05:23 +0000 | [diff] [blame] | 1147 | unsigned getMinNumVGPRs(unsigned WavesPerEU) const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 1148 | return AMDGPU::IsaInfo::getMinNumVGPRs(this, WavesPerEU); |
Konstantin Zhuravlyov | 9f89ede | 2017-02-08 14:05:23 +0000 | [diff] [blame] | 1149 | } |
Konstantin Zhuravlyov | e03b1d7 | 2017-02-08 13:02:33 +0000 | [diff] [blame] | 1150 | |
| 1151 | /// \returns Maximum number of VGPRs that meets given number of waves per |
| 1152 | /// execution unit requirement supported by the subtarget. |
Konstantin Zhuravlyov | 9f89ede | 2017-02-08 14:05:23 +0000 | [diff] [blame] | 1153 | unsigned getMaxNumVGPRs(unsigned WavesPerEU) const { |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 1154 | return AMDGPU::IsaInfo::getMaxNumVGPRs(this, WavesPerEU); |
Konstantin Zhuravlyov | 9f89ede | 2017-02-08 14:05:23 +0000 | [diff] [blame] | 1155 | } |
Konstantin Zhuravlyov | e03b1d7 | 2017-02-08 13:02:33 +0000 | [diff] [blame] | 1156 | |
Konstantin Zhuravlyov | e03b1d7 | 2017-02-08 13:02:33 +0000 | [diff] [blame] | 1157 | /// \returns Maximum number of VGPRs that meets number of waves per execution |
| 1158 | /// unit requirement for function \p MF, or number of VGPRs explicitly |
| 1159 | /// requested using "amdgpu-num-vgpr" attribute attached to function \p MF. |
| 1160 | /// |
| 1161 | /// \returns Value that meets number of waves per execution unit requirement |
| 1162 | /// if explicitly requested value cannot be converted to integer, violates |
| 1163 | /// subtarget's specifications, or does not meet number of waves per execution |
| 1164 | /// unit requirement. |
| 1165 | unsigned getMaxNumVGPRs(const MachineFunction &MF) const; |
Stanislav Mekhanoshin | d4ae470 | 2017-09-19 20:54:38 +0000 | [diff] [blame] | 1166 | |
| 1167 | void getPostRAMutations( |
| 1168 | std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) |
| 1169 | const override; |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 1170 | |
Stanislav Mekhanoshin | 68a2fef | 2019-06-13 23:47:36 +0000 | [diff] [blame] | 1171 | bool isWave32() const { |
| 1172 | return WavefrontSize == 32; |
| 1173 | } |
| 1174 | |
Stanislav Mekhanoshin | 5250021 | 2019-06-16 17:13:09 +0000 | [diff] [blame] | 1175 | const TargetRegisterClass *getBoolRC() const { |
| 1176 | return getRegisterInfo()->getBoolRC(); |
| 1177 | } |
| 1178 | |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 1179 | /// \returns Maximum number of work groups per compute unit supported by the |
| 1180 | /// subtarget and limited by given \p FlatWorkGroupSize. |
| 1181 | unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const override { |
| 1182 | return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(this, FlatWorkGroupSize); |
| 1183 | } |
| 1184 | |
| 1185 | /// \returns Minimum flat work group size supported by the subtarget. |
| 1186 | unsigned getMinFlatWorkGroupSize() const override { |
| 1187 | return AMDGPU::IsaInfo::getMinFlatWorkGroupSize(this); |
| 1188 | } |
| 1189 | |
| 1190 | /// \returns Maximum flat work group size supported by the subtarget. |
| 1191 | unsigned getMaxFlatWorkGroupSize() const override { |
| 1192 | return AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(this); |
| 1193 | } |
| 1194 | |
| 1195 | /// \returns Maximum number of waves per execution unit supported by the |
| 1196 | /// subtarget and limited by given \p FlatWorkGroupSize. |
| 1197 | unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const override { |
| 1198 | return AMDGPU::IsaInfo::getMaxWavesPerEU(this, FlatWorkGroupSize); |
| 1199 | } |
| 1200 | |
| 1201 | /// \returns Minimum number of waves per execution unit supported by the |
| 1202 | /// subtarget. |
| 1203 | unsigned getMinWavesPerEU() const override { |
| 1204 | return AMDGPU::IsaInfo::getMinWavesPerEU(this); |
| 1205 | } |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 1206 | }; |
| 1207 | |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 1208 | class R600Subtarget final : public R600GenSubtargetInfo, |
Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 1209 | public AMDGPUSubtarget { |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 1210 | private: |
| 1211 | R600InstrInfo InstrInfo; |
| 1212 | R600FrameLowering FrameLowering; |
| 1213 | bool FMA; |
| 1214 | bool CaymanISA; |
| 1215 | bool CFALUBug; |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 1216 | bool HasVertexCache; |
| 1217 | bool R600ALUInst; |
| 1218 | bool FP64; |
| 1219 | short TexVTXClauseSize; |
| 1220 | Generation Gen; |
| 1221 | R600TargetLowering TLInfo; |
| 1222 | InstrItineraryData InstrItins; |
| 1223 | SelectionDAGTargetInfo TSInfo; |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 1224 | |
| 1225 | public: |
| 1226 | R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS, |
| 1227 | const TargetMachine &TM); |
| 1228 | |
| 1229 | const R600InstrInfo *getInstrInfo() const override { return &InstrInfo; } |
| 1230 | |
| 1231 | const R600FrameLowering *getFrameLowering() const override { |
| 1232 | return &FrameLowering; |
| 1233 | } |
| 1234 | |
| 1235 | const R600TargetLowering *getTargetLowering() const override { |
| 1236 | return &TLInfo; |
| 1237 | } |
| 1238 | |
| 1239 | const R600RegisterInfo *getRegisterInfo() const override { |
| 1240 | return &InstrInfo.getRegisterInfo(); |
| 1241 | } |
| 1242 | |
| 1243 | const InstrItineraryData *getInstrItineraryData() const override { |
| 1244 | return &InstrItins; |
| 1245 | } |
| 1246 | |
| 1247 | // Nothing implemented, just prevent crashes on use. |
| 1248 | const SelectionDAGTargetInfo *getSelectionDAGInfo() const override { |
| 1249 | return &TSInfo; |
| 1250 | } |
| 1251 | |
| 1252 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); |
| 1253 | |
| 1254 | Generation getGeneration() const { |
| 1255 | return Gen; |
| 1256 | } |
| 1257 | |
| 1258 | unsigned getStackAlignment() const { |
| 1259 | return 4; |
| 1260 | } |
| 1261 | |
| 1262 | R600Subtarget &initializeSubtargetDependencies(const Triple &TT, |
| 1263 | StringRef GPU, StringRef FS); |
| 1264 | |
| 1265 | bool hasBFE() const { |
| 1266 | return (getGeneration() >= EVERGREEN); |
| 1267 | } |
| 1268 | |
| 1269 | bool hasBFI() const { |
| 1270 | return (getGeneration() >= EVERGREEN); |
| 1271 | } |
| 1272 | |
| 1273 | bool hasBCNT(unsigned Size) const { |
| 1274 | if (Size == 32) |
| 1275 | return (getGeneration() >= EVERGREEN); |
| 1276 | |
| 1277 | return false; |
| 1278 | } |
| 1279 | |
| 1280 | bool hasBORROW() const { |
| 1281 | return (getGeneration() >= EVERGREEN); |
| 1282 | } |
| 1283 | |
| 1284 | bool hasCARRY() const { |
| 1285 | return (getGeneration() >= EVERGREEN); |
| 1286 | } |
| 1287 | |
| 1288 | bool hasCaymanISA() const { |
| 1289 | return CaymanISA; |
| 1290 | } |
| 1291 | |
| 1292 | bool hasFFBL() const { |
| 1293 | return (getGeneration() >= EVERGREEN); |
| 1294 | } |
| 1295 | |
| 1296 | bool hasFFBH() const { |
| 1297 | return (getGeneration() >= EVERGREEN); |
| 1298 | } |
| 1299 | |
| 1300 | bool hasFMA() const { return FMA; } |
| 1301 | |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 1302 | bool hasCFAluBug() const { return CFALUBug; } |
| 1303 | |
| 1304 | bool hasVertexCache() const { return HasVertexCache; } |
| 1305 | |
| 1306 | short getTexVTXClauseSize() const { return TexVTXClauseSize; } |
| 1307 | |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 1308 | bool enableMachineScheduler() const override { |
| 1309 | return true; |
| 1310 | } |
| 1311 | |
| 1312 | bool enableSubRegLiveness() const override { |
| 1313 | return true; |
| 1314 | } |
Konstantin Zhuravlyov | 71e43ee | 2018-09-12 18:50:47 +0000 | [diff] [blame] | 1315 | |
| 1316 | /// \returns Maximum number of work groups per compute unit supported by the |
| 1317 | /// subtarget and limited by given \p FlatWorkGroupSize. |
| 1318 | unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const override { |
| 1319 | return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(this, FlatWorkGroupSize); |
| 1320 | } |
| 1321 | |
| 1322 | /// \returns Minimum flat work group size supported by the subtarget. |
| 1323 | unsigned getMinFlatWorkGroupSize() const override { |
| 1324 | return AMDGPU::IsaInfo::getMinFlatWorkGroupSize(this); |
| 1325 | } |
| 1326 | |
| 1327 | /// \returns Maximum flat work group size supported by the subtarget. |
| 1328 | unsigned getMaxFlatWorkGroupSize() const override { |
| 1329 | return AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(this); |
| 1330 | } |
| 1331 | |
| 1332 | /// \returns Maximum number of waves per execution unit supported by the |
| 1333 | /// subtarget and limited by given \p FlatWorkGroupSize. |
| 1334 | unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const override { |
| 1335 | return AMDGPU::IsaInfo::getMaxWavesPerEU(this, FlatWorkGroupSize); |
| 1336 | } |
| 1337 | |
| 1338 | /// \returns Minimum number of waves per execution unit supported by the |
| 1339 | /// subtarget. |
| 1340 | unsigned getMinWavesPerEU() const override { |
| 1341 | return AMDGPU::IsaInfo::getMinWavesPerEU(this); |
| 1342 | } |
Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 1343 | }; |
| 1344 | |
Eugene Zelenko | 2bc2f33 | 2016-12-09 22:06:55 +0000 | [diff] [blame] | 1345 | } // end namespace llvm |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 1346 | |
Eugene Zelenko | 2bc2f33 | 2016-12-09 22:06:55 +0000 | [diff] [blame] | 1347 | #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H |