1 //===-- SIISelLowering.h - SI DAG Lowering Interface ------------*- 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 /// \file 10 /// SI DAG Lowering interface definition 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_LIB_TARGET_AMDGPU_SIISELLOWERING_H 15 #define LLVM_LIB_TARGET_AMDGPU_SIISELLOWERING_H 16 17 #include "AMDGPUISelLowering.h" 18 #include "AMDGPUArgumentUsageInfo.h" 19 #include "llvm/CodeGen/MachineFunction.h" 20 21 namespace llvm { 22 23 class GCNSubtarget; 24 class SIMachineFunctionInfo; 25 class SIRegisterInfo; 26 27 namespace AMDGPU { 28 struct ImageDimIntrinsicInfo; 29 } 30 31 class SITargetLowering final : public AMDGPUTargetLowering { 32 private: 33 const GCNSubtarget *Subtarget; 34 35 public: 36 MVT getRegisterTypeForCallingConv(LLVMContext &Context, 37 CallingConv::ID CC, 38 EVT VT) const override; 39 unsigned getNumRegistersForCallingConv(LLVMContext &Context, 40 CallingConv::ID CC, 41 EVT VT) const override; 42 43 unsigned getVectorTypeBreakdownForCallingConv( 44 LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT, 45 unsigned &NumIntermediates, MVT &RegisterVT) const override; 46 47 private: 48 SDValue lowerKernArgParameterPtr(SelectionDAG &DAG, const SDLoc &SL, 49 SDValue Chain, uint64_t Offset) const; 50 SDValue getImplicitArgPtr(SelectionDAG &DAG, const SDLoc &SL) const; 51 SDValue lowerKernargMemParameter(SelectionDAG &DAG, EVT VT, EVT MemVT, 52 const SDLoc &SL, SDValue Chain, 53 uint64_t Offset, Align Alignment, 54 bool Signed, 55 const ISD::InputArg *Arg = nullptr) const; 56 SDValue loadImplicitKernelArgument(SelectionDAG &DAG, MVT VT, const SDLoc &DL, 57 Align Alignment, 58 ImplicitParameter Param) const; 59 60 SDValue lowerStackParameter(SelectionDAG &DAG, CCValAssign &VA, 61 const SDLoc &SL, SDValue Chain, 62 const ISD::InputArg &Arg) const; 63 SDValue getPreloadedValue(SelectionDAG &DAG, 64 const SIMachineFunctionInfo &MFI, 65 EVT VT, 66 AMDGPUFunctionArgInfo::PreloadedValue) const; 67 68 SDValue LowerGlobalAddress(AMDGPUMachineFunction *MFI, SDValue Op, 69 SelectionDAG &DAG) const override; 70 SDValue lowerImplicitZextParam(SelectionDAG &DAG, SDValue Op, 71 MVT VT, unsigned Offset) const; 72 SDValue lowerImage(SDValue Op, const AMDGPU::ImageDimIntrinsicInfo *Intr, 73 SelectionDAG &DAG, bool WithChain) const; 74 SDValue lowerSBuffer(EVT VT, SDLoc DL, SDValue Rsrc, SDValue Offset, 75 SDValue CachePolicy, SelectionDAG &DAG) const; 76 77 SDValue lowerRawBufferAtomicIntrin(SDValue Op, SelectionDAG &DAG, 78 unsigned NewOpcode) const; 79 SDValue lowerStructBufferAtomicIntrin(SDValue Op, SelectionDAG &DAG, 80 unsigned NewOpcode) const; 81 82 SDValue lowerWorkitemID(SelectionDAG &DAG, SDValue Op, unsigned Dim, 83 const ArgDescriptor &ArgDesc) const; 84 85 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const; 86 SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const; 87 SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const; 88 89 // The raw.tbuffer and struct.tbuffer intrinsics have two offset args: offset 90 // (the offset that is included in bounds checking and swizzling, to be split 91 // between the instruction's voffset and immoffset fields) and soffset (the 92 // offset that is excluded from bounds checking and swizzling, to go in the 93 // instruction's soffset field). This function takes the first kind of 94 // offset and figures out how to split it between voffset and immoffset. 95 std::pair<SDValue, SDValue> splitBufferOffsets(SDValue Offset, 96 SelectionDAG &DAG) const; 97 98 SDValue widenLoad(LoadSDNode *Ld, DAGCombinerInfo &DCI) const; 99 SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const; 100 SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const; 101 SDValue lowerFastUnsafeFDIV(SDValue Op, SelectionDAG &DAG) const; 102 SDValue lowerFastUnsafeFDIV64(SDValue Op, SelectionDAG &DAG) const; 103 SDValue lowerFDIV_FAST(SDValue Op, SelectionDAG &DAG) const; 104 SDValue LowerFDIV16(SDValue Op, SelectionDAG &DAG) const; 105 SDValue LowerFDIV32(SDValue Op, SelectionDAG &DAG) const; 106 SDValue LowerFDIV64(SDValue Op, SelectionDAG &DAG) const; 107 SDValue LowerFDIV(SDValue Op, SelectionDAG &DAG) const; 108 SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const; 109 SDValue LowerTrig(SDValue Op, SelectionDAG &DAG) const; 110 SDValue LowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const; 111 SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const; 112 SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const; 113 SDValue adjustLoadValueType(unsigned Opcode, MemSDNode *M, 114 SelectionDAG &DAG, ArrayRef<SDValue> Ops, 115 bool IsIntrinsic = false) const; 116 117 SDValue lowerIntrinsicLoad(MemSDNode *M, bool IsFormat, SelectionDAG &DAG, 118 ArrayRef<SDValue> Ops) const; 119 120 // Call DAG.getMemIntrinsicNode for a load, but first widen a dwordx3 type to 121 // dwordx4 if on SI. 122 SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, 123 ArrayRef<SDValue> Ops, EVT MemVT, 124 MachineMemOperand *MMO, SelectionDAG &DAG) const; 125 126 SDValue handleD16VData(SDValue VData, SelectionDAG &DAG, 127 bool ImageStore = false) const; 128 129 /// Converts \p Op, which must be of floating point type, to the 130 /// floating point type \p VT, by either extending or truncating it. 131 SDValue getFPExtOrFPRound(SelectionDAG &DAG, 132 SDValue Op, 133 const SDLoc &DL, 134 EVT VT) const; 135 136 SDValue convertArgType( 137 SelectionDAG &DAG, EVT VT, EVT MemVT, const SDLoc &SL, SDValue Val, 138 bool Signed, const ISD::InputArg *Arg = nullptr) const; 139 140 /// Custom lowering for ISD::FP_ROUND for MVT::f16. 141 SDValue lowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const; 142 SDValue lowerFMINNUM_FMAXNUM(SDValue Op, SelectionDAG &DAG) const; 143 SDValue lowerXMULO(SDValue Op, SelectionDAG &DAG) const; 144 SDValue lowerXMUL_LOHI(SDValue Op, SelectionDAG &DAG) const; 145 146 SDValue getSegmentAperture(unsigned AS, const SDLoc &DL, 147 SelectionDAG &DAG) const; 148 149 SDValue lowerADDRSPACECAST(SDValue Op, SelectionDAG &DAG) const; 150 SDValue lowerINSERT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const; 151 SDValue lowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const; 152 SDValue lowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const; 153 SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const; 154 SDValue lowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const; 155 156 SDValue lowerTRAP(SDValue Op, SelectionDAG &DAG) const; 157 SDValue lowerTrapEndpgm(SDValue Op, SelectionDAG &DAG) const; 158 SDValue lowerTrapHsaQueuePtr(SDValue Op, SelectionDAG &DAG) const; 159 SDValue lowerTrapHsa(SDValue Op, SelectionDAG &DAG) const; 160 SDValue lowerDEBUGTRAP(SDValue Op, SelectionDAG &DAG) const; 161 162 SDNode *adjustWritemask(MachineSDNode *&N, SelectionDAG &DAG) const; 163 164 SDValue performUCharToFloatCombine(SDNode *N, 165 DAGCombinerInfo &DCI) const; 166 SDValue performSHLPtrCombine(SDNode *N, 167 unsigned AS, 168 EVT MemVT, 169 DAGCombinerInfo &DCI) const; 170 171 SDValue performMemSDNodeCombine(MemSDNode *N, DAGCombinerInfo &DCI) const; 172 173 SDValue splitBinaryBitConstantOp(DAGCombinerInfo &DCI, const SDLoc &SL, 174 unsigned Opc, SDValue LHS, 175 const ConstantSDNode *CRHS) const; 176 177 SDValue performAndCombine(SDNode *N, DAGCombinerInfo &DCI) const; 178 SDValue performOrCombine(SDNode *N, DAGCombinerInfo &DCI) const; 179 SDValue performXorCombine(SDNode *N, DAGCombinerInfo &DCI) const; 180 SDValue performZeroExtendCombine(SDNode *N, DAGCombinerInfo &DCI) const; 181 SDValue performSignExtendInRegCombine(SDNode *N, DAGCombinerInfo &DCI) const; 182 SDValue performClassCombine(SDNode *N, DAGCombinerInfo &DCI) const; 183 SDValue getCanonicalConstantFP(SelectionDAG &DAG, const SDLoc &SL, EVT VT, 184 const APFloat &C) const; 185 SDValue performFCanonicalizeCombine(SDNode *N, DAGCombinerInfo &DCI) const; 186 187 SDValue performFPMed3ImmCombine(SelectionDAG &DAG, const SDLoc &SL, 188 SDValue Op0, SDValue Op1) const; 189 SDValue performIntMed3ImmCombine(SelectionDAG &DAG, const SDLoc &SL, 190 SDValue Op0, SDValue Op1, bool Signed) const; 191 SDValue performMinMaxCombine(SDNode *N, DAGCombinerInfo &DCI) const; 192 SDValue performFMed3Combine(SDNode *N, DAGCombinerInfo &DCI) const; 193 SDValue performCvtPkRTZCombine(SDNode *N, DAGCombinerInfo &DCI) const; 194 SDValue performExtractVectorEltCombine(SDNode *N, DAGCombinerInfo &DCI) const; 195 SDValue performInsertVectorEltCombine(SDNode *N, DAGCombinerInfo &DCI) const; 196 197 SDValue reassociateScalarOps(SDNode *N, SelectionDAG &DAG) const; 198 unsigned getFusedOpcode(const SelectionDAG &DAG, 199 const SDNode *N0, const SDNode *N1) const; 200 SDValue performAddCombine(SDNode *N, DAGCombinerInfo &DCI) const; 201 SDValue performAddCarrySubCarryCombine(SDNode *N, DAGCombinerInfo &DCI) const; 202 SDValue performSubCombine(SDNode *N, DAGCombinerInfo &DCI) const; 203 SDValue performFAddCombine(SDNode *N, DAGCombinerInfo &DCI) const; 204 SDValue performFSubCombine(SDNode *N, DAGCombinerInfo &DCI) const; 205 SDValue performFMACombine(SDNode *N, DAGCombinerInfo &DCI) const; 206 SDValue performSetCCCombine(SDNode *N, DAGCombinerInfo &DCI) const; 207 SDValue performCvtF32UByteNCombine(SDNode *N, DAGCombinerInfo &DCI) const; 208 SDValue performClampCombine(SDNode *N, DAGCombinerInfo &DCI) const; 209 SDValue performRcpCombine(SDNode *N, DAGCombinerInfo &DCI) const; 210 211 bool isLegalFlatAddressingMode(const AddrMode &AM) const; 212 bool isLegalMUBUFAddressingMode(const AddrMode &AM) const; 213 214 unsigned isCFIntrinsic(const SDNode *Intr) const; 215 216 public: 217 /// \returns True if fixup needs to be emitted for given global value \p GV, 218 /// false otherwise. 219 bool shouldEmitFixup(const GlobalValue *GV) const; 220 221 /// \returns True if GOT relocation needs to be emitted for given global value 222 /// \p GV, false otherwise. 223 bool shouldEmitGOTReloc(const GlobalValue *GV) const; 224 225 /// \returns True if PC-relative relocation needs to be emitted for given 226 /// global value \p GV, false otherwise. 227 bool shouldEmitPCReloc(const GlobalValue *GV) const; 228 229 /// \returns true if this should use a literal constant for an LDS address, 230 /// and not emit a relocation for an LDS global. 231 bool shouldUseLDSConstAddress(const GlobalValue *GV) const; 232 233 /// Check if EXTRACT_VECTOR_ELT/INSERT_VECTOR_ELT (<n x e>, var-idx) should be 234 /// expanded into a set of cmp/select instructions. 235 static bool shouldExpandVectorDynExt(unsigned EltSize, unsigned NumElem, 236 bool IsDivergentIdx); 237 238 private: 239 // Analyze a combined offset from an amdgcn_buffer_ intrinsic and store the 240 // three offsets (voffset, soffset and instoffset) into the SDValue[3] array 241 // pointed to by Offsets. 242 void setBufferOffsets(SDValue CombinedOffset, SelectionDAG &DAG, 243 SDValue *Offsets, Align Alignment = Align(4)) const; 244 245 // Handle 8 bit and 16 bit buffer loads 246 SDValue handleByteShortBufferLoads(SelectionDAG &DAG, EVT LoadVT, SDLoc DL, 247 ArrayRef<SDValue> Ops, MemSDNode *M) const; 248 249 // Handle 8 bit and 16 bit buffer stores 250 SDValue handleByteShortBufferStores(SelectionDAG &DAG, EVT VDataType, 251 SDLoc DL, SDValue Ops[], 252 MemSDNode *M) const; 253 254 public: 255 SITargetLowering(const TargetMachine &tm, const GCNSubtarget &STI); 256 257 const GCNSubtarget *getSubtarget() const; 258 259 bool isFPExtFoldable(const SelectionDAG &DAG, unsigned Opcode, EVT DestVT, 260 EVT SrcVT) const override; 261 262 bool isFPExtFoldable(const MachineInstr &MI, unsigned Opcode, LLT DestTy, 263 LLT SrcTy) const override; 264 265 bool isShuffleMaskLegal(ArrayRef<int> /*Mask*/, EVT /*VT*/) const override; 266 267 bool getTgtMemIntrinsic(IntrinsicInfo &, const CallInst &, 268 MachineFunction &MF, 269 unsigned IntrinsicID) const override; 270 271 bool getAddrModeArguments(IntrinsicInst * /*I*/, 272 SmallVectorImpl<Value*> &/*Ops*/, 273 Type *&/*AccessTy*/) const override; 274 275 bool isLegalGlobalAddressingMode(const AddrMode &AM) const; 276 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, 277 unsigned AS, 278 Instruction *I = nullptr) const override; 279 280 bool canMergeStoresTo(unsigned AS, EVT MemVT, 281 const MachineFunction &MF) const override; 282 283 bool allowsMisalignedMemoryAccessesImpl( 284 unsigned Size, unsigned AddrSpace, Align Alignment, 285 MachineMemOperand::Flags Flags = MachineMemOperand::MONone, 286 bool *IsFast = nullptr) const; 287 288 bool allowsMisalignedMemoryAccesses( 289 LLT Ty, unsigned AddrSpace, Align Alignment, 290 MachineMemOperand::Flags Flags = MachineMemOperand::MONone, 291 bool *IsFast = nullptr) const override { 292 if (IsFast) 293 *IsFast = false; 294 return allowsMisalignedMemoryAccessesImpl(Ty.getSizeInBits(), AddrSpace, 295 Alignment, Flags, IsFast); 296 } 297 298 bool allowsMisalignedMemoryAccesses( 299 EVT VT, unsigned AS, Align Alignment, 300 MachineMemOperand::Flags Flags = MachineMemOperand::MONone, 301 bool *IsFast = nullptr) const override; 302 303 EVT getOptimalMemOpType(const MemOp &Op, 304 const AttributeList &FuncAttributes) const override; 305 306 bool isMemOpUniform(const SDNode *N) const; 307 bool isMemOpHasNoClobberedMemOperand(const SDNode *N) const; 308 309 static bool isNonGlobalAddrSpace(unsigned AS); 310 311 bool isFreeAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override; 312 313 TargetLoweringBase::LegalizeTypeAction 314 getPreferredVectorAction(MVT VT) const override; 315 316 bool shouldConvertConstantLoadToIntImm(const APInt &Imm, 317 Type *Ty) const override; 318 319 bool isTypeDesirableForOp(unsigned Op, EVT VT) const override; 320 321 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override; 322 323 bool supportSplitCSR(MachineFunction *MF) const override; 324 void initializeSplitCSR(MachineBasicBlock *Entry) const override; 325 void insertCopiesSplitCSR( 326 MachineBasicBlock *Entry, 327 const SmallVectorImpl<MachineBasicBlock *> &Exits) const override; 328 329 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, 330 bool isVarArg, 331 const SmallVectorImpl<ISD::InputArg> &Ins, 332 const SDLoc &DL, SelectionDAG &DAG, 333 SmallVectorImpl<SDValue> &InVals) const override; 334 335 bool CanLowerReturn(CallingConv::ID CallConv, 336 MachineFunction &MF, bool isVarArg, 337 const SmallVectorImpl<ISD::OutputArg> &Outs, 338 LLVMContext &Context) const override; 339 340 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, 341 const SmallVectorImpl<ISD::OutputArg> &Outs, 342 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL, 343 SelectionDAG &DAG) const override; 344 345 void passSpecialInputs( 346 CallLoweringInfo &CLI, 347 CCState &CCInfo, 348 const SIMachineFunctionInfo &Info, 349 SmallVectorImpl<std::pair<unsigned, SDValue>> &RegsToPass, 350 SmallVectorImpl<SDValue> &MemOpChains, 351 SDValue Chain) const; 352 353 SDValue LowerCallResult(SDValue Chain, SDValue InFlag, 354 CallingConv::ID CallConv, bool isVarArg, 355 const SmallVectorImpl<ISD::InputArg> &Ins, 356 const SDLoc &DL, SelectionDAG &DAG, 357 SmallVectorImpl<SDValue> &InVals, bool isThisReturn, 358 SDValue ThisVal) const; 359 360 bool mayBeEmittedAsTailCall(const CallInst *) const override; 361 362 bool isEligibleForTailCallOptimization( 363 SDValue Callee, CallingConv::ID CalleeCC, bool isVarArg, 364 const SmallVectorImpl<ISD::OutputArg> &Outs, 365 const SmallVectorImpl<SDValue> &OutVals, 366 const SmallVectorImpl<ISD::InputArg> &Ins, SelectionDAG &DAG) const; 367 368 SDValue LowerCall(CallLoweringInfo &CLI, 369 SmallVectorImpl<SDValue> &InVals) const override; 370 371 SDValue lowerDYNAMIC_STACKALLOCImpl(SDValue Op, SelectionDAG &DAG) const; 372 SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const; 373 374 Register getRegisterByName(const char* RegName, LLT VT, 375 const MachineFunction &MF) const override; 376 377 MachineBasicBlock *splitKillBlock(MachineInstr &MI, 378 MachineBasicBlock *BB) const; 379 380 void bundleInstWithWaitcnt(MachineInstr &MI) const; 381 MachineBasicBlock *emitGWSMemViolTestLoop(MachineInstr &MI, 382 MachineBasicBlock *BB) const; 383 384 MachineBasicBlock * 385 EmitInstrWithCustomInserter(MachineInstr &MI, 386 MachineBasicBlock *BB) const override; 387 388 bool hasBitPreservingFPLogic(EVT VT) const override; 389 bool enableAggressiveFMAFusion(EVT VT) const override; 390 bool enableAggressiveFMAFusion(LLT Ty) const override; 391 EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, 392 EVT VT) const override; 393 MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override; 394 LLT getPreferredShiftAmountTy(LLT Ty) const override; 395 396 bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF, 397 EVT VT) const override; 398 bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF, 399 const LLT Ty) const override; 400 bool isFMADLegal(const SelectionDAG &DAG, const SDNode *N) const override; 401 bool isFMADLegal(const MachineInstr &MI, const LLT Ty) const override; 402 403 SDValue splitUnaryVectorOp(SDValue Op, SelectionDAG &DAG) const; 404 SDValue splitBinaryVectorOp(SDValue Op, SelectionDAG &DAG) const; 405 SDValue splitTernaryVectorOp(SDValue Op, SelectionDAG &DAG) const; 406 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override; 407 408 void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results, 409 SelectionDAG &DAG) const override; 410 411 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override; 412 SDNode *PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const override; 413 void AddIMGInit(MachineInstr &MI) const; 414 void AdjustInstrPostInstrSelection(MachineInstr &MI, 415 SDNode *Node) const override; 416 417 SDNode *legalizeTargetIndependentNode(SDNode *Node, SelectionDAG &DAG) const; 418 419 MachineSDNode *wrapAddr64Rsrc(SelectionDAG &DAG, const SDLoc &DL, 420 SDValue Ptr) const; 421 MachineSDNode *buildRSRC(SelectionDAG &DAG, const SDLoc &DL, SDValue Ptr, 422 uint32_t RsrcDword1, uint64_t RsrcDword2And3) const; 423 std::pair<unsigned, const TargetRegisterClass *> 424 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, 425 StringRef Constraint, MVT VT) const override; 426 ConstraintType getConstraintType(StringRef Constraint) const override; 427 void LowerAsmOperandForConstraint(SDValue Op, 428 std::string &Constraint, 429 std::vector<SDValue> &Ops, 430 SelectionDAG &DAG) const override; 431 bool getAsmOperandConstVal(SDValue Op, uint64_t &Val) const; 432 bool checkAsmConstraintVal(SDValue Op, 433 const std::string &Constraint, 434 uint64_t Val) const; 435 bool checkAsmConstraintValA(SDValue Op, 436 uint64_t Val, 437 unsigned MaxSize = 64) const; 438 SDValue copyToM0(SelectionDAG &DAG, SDValue Chain, const SDLoc &DL, 439 SDValue V) const; 440 441 void finalizeLowering(MachineFunction &MF) const override; 442 443 void computeKnownBitsForFrameIndex(int FrameIdx, 444 KnownBits &Known, 445 const MachineFunction &MF) const override; 446 void computeKnownBitsForTargetInstr(GISelKnownBits &Analysis, Register R, 447 KnownBits &Known, 448 const APInt &DemandedElts, 449 const MachineRegisterInfo &MRI, 450 unsigned Depth = 0) const override; 451 452 Align computeKnownAlignForTargetInstr(GISelKnownBits &Analysis, Register R, 453 const MachineRegisterInfo &MRI, 454 unsigned Depth = 0) const override; 455 bool isSDNodeSourceOfDivergence(const SDNode *N, 456 FunctionLoweringInfo *FLI, LegacyDivergenceAnalysis *DA) const override; 457 458 bool hasMemSDNodeUser(SDNode *N) const; 459 460 bool isReassocProfitable(SelectionDAG &DAG, SDValue N0, 461 SDValue N1) const override; 462 463 bool isCanonicalized(SelectionDAG &DAG, SDValue Op, 464 unsigned MaxDepth = 5) const; 465 bool isCanonicalized(Register Reg, MachineFunction &MF, 466 unsigned MaxDepth = 5) const; 467 bool denormalsEnabledForType(const SelectionDAG &DAG, EVT VT) const; 468 bool denormalsEnabledForType(LLT Ty, MachineFunction &MF) const; 469 470 bool isKnownNeverNaNForTargetNode(SDValue Op, 471 const SelectionDAG &DAG, 472 bool SNaN = false, 473 unsigned Depth = 0) const override; 474 AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *) const override; 475 AtomicExpansionKind shouldExpandAtomicLoadInIR(LoadInst *LI) const override; 476 AtomicExpansionKind shouldExpandAtomicStoreInIR(StoreInst *SI) const override; 477 AtomicExpansionKind 478 shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override; 479 480 virtual const TargetRegisterClass * 481 getRegClassFor(MVT VT, bool isDivergent) const override; 482 virtual bool requiresUniformRegister(MachineFunction &MF, 483 const Value *V) const override; 484 Align getPrefLoopAlignment(MachineLoop *ML) const override; 485 486 void allocateHSAUserSGPRs(CCState &CCInfo, 487 MachineFunction &MF, 488 const SIRegisterInfo &TRI, 489 SIMachineFunctionInfo &Info) const; 490 491 void allocateSystemSGPRs(CCState &CCInfo, 492 MachineFunction &MF, 493 SIMachineFunctionInfo &Info, 494 CallingConv::ID CallConv, 495 bool IsShader) const; 496 497 void allocateSpecialEntryInputVGPRs(CCState &CCInfo, 498 MachineFunction &MF, 499 const SIRegisterInfo &TRI, 500 SIMachineFunctionInfo &Info) const; 501 void allocateSpecialInputSGPRs( 502 CCState &CCInfo, 503 MachineFunction &MF, 504 const SIRegisterInfo &TRI, 505 SIMachineFunctionInfo &Info) const; 506 507 void allocateSpecialInputVGPRs(CCState &CCInfo, 508 MachineFunction &MF, 509 const SIRegisterInfo &TRI, 510 SIMachineFunctionInfo &Info) const; 511 void allocateSpecialInputVGPRsFixed(CCState &CCInfo, 512 MachineFunction &MF, 513 const SIRegisterInfo &TRI, 514 SIMachineFunctionInfo &Info) const; 515 516 std::pair<InstructionCost, MVT> getTypeLegalizationCost(const DataLayout &DL, 517 Type *Ty) const; 518 519 MachineMemOperand::Flags 520 getTargetMMOFlags(const Instruction &I) const override; 521 }; 522 523 } // End namespace llvm 524 525 #endif 526