xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/SIISelLowering.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric //===-- SIISelLowering.h - SI DAG Lowering Interface ------------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric /// \file
100b57cec5SDimitry Andric /// SI DAG Lowering interface definition
110b57cec5SDimitry Andric //
120b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
130b57cec5SDimitry Andric 
140b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_AMDGPU_SIISELLOWERING_H
150b57cec5SDimitry Andric #define LLVM_LIB_TARGET_AMDGPU_SIISELLOWERING_H
160b57cec5SDimitry Andric 
170b57cec5SDimitry Andric #include "AMDGPUISelLowering.h"
180b57cec5SDimitry Andric #include "AMDGPUArgumentUsageInfo.h"
19349cc55cSDimitry Andric #include "llvm/CodeGen/MachineFunction.h"
200b57cec5SDimitry Andric 
210b57cec5SDimitry Andric namespace llvm {
220b57cec5SDimitry Andric 
23e8d8bef9SDimitry Andric class GCNSubtarget;
24e8d8bef9SDimitry Andric class SIMachineFunctionInfo;
25e8d8bef9SDimitry Andric class SIRegisterInfo;
26e8d8bef9SDimitry Andric 
27e8d8bef9SDimitry Andric namespace AMDGPU {
28e8d8bef9SDimitry Andric struct ImageDimIntrinsicInfo;
29e8d8bef9SDimitry Andric }
30e8d8bef9SDimitry Andric 
310b57cec5SDimitry Andric class SITargetLowering final : public AMDGPUTargetLowering {
320b57cec5SDimitry Andric private:
330b57cec5SDimitry Andric   const GCNSubtarget *Subtarget;
340b57cec5SDimitry Andric 
350b57cec5SDimitry Andric public:
360b57cec5SDimitry Andric   MVT getRegisterTypeForCallingConv(LLVMContext &Context,
370b57cec5SDimitry Andric                                     CallingConv::ID CC,
380b57cec5SDimitry Andric                                     EVT VT) const override;
390b57cec5SDimitry Andric   unsigned getNumRegistersForCallingConv(LLVMContext &Context,
400b57cec5SDimitry Andric                                          CallingConv::ID CC,
410b57cec5SDimitry Andric                                          EVT VT) const override;
420b57cec5SDimitry Andric 
430b57cec5SDimitry Andric   unsigned getVectorTypeBreakdownForCallingConv(
440b57cec5SDimitry Andric     LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT,
450b57cec5SDimitry Andric     unsigned &NumIntermediates, MVT &RegisterVT) const override;
460b57cec5SDimitry Andric 
470b57cec5SDimitry Andric private:
480b57cec5SDimitry Andric   SDValue lowerKernArgParameterPtr(SelectionDAG &DAG, const SDLoc &SL,
490b57cec5SDimitry Andric                                    SDValue Chain, uint64_t Offset) const;
500b57cec5SDimitry Andric   SDValue getImplicitArgPtr(SelectionDAG &DAG, const SDLoc &SL) const;
51fcaf7f86SDimitry Andric   SDValue getLDSKernelId(SelectionDAG &DAG, const SDLoc &SL) const;
520b57cec5SDimitry Andric   SDValue lowerKernargMemParameter(SelectionDAG &DAG, EVT VT, EVT MemVT,
530b57cec5SDimitry Andric                                    const SDLoc &SL, SDValue Chain,
545ffd83dbSDimitry Andric                                    uint64_t Offset, Align Alignment,
555ffd83dbSDimitry Andric                                    bool Signed,
560b57cec5SDimitry Andric                                    const ISD::InputArg *Arg = nullptr) const;
5781ad6265SDimitry Andric   SDValue loadImplicitKernelArgument(SelectionDAG &DAG, MVT VT, const SDLoc &DL,
5881ad6265SDimitry Andric                                      Align Alignment,
5981ad6265SDimitry Andric                                      ImplicitParameter Param) const;
600b57cec5SDimitry Andric 
610b57cec5SDimitry Andric   SDValue lowerStackParameter(SelectionDAG &DAG, CCValAssign &VA,
620b57cec5SDimitry Andric                               const SDLoc &SL, SDValue Chain,
630b57cec5SDimitry Andric                               const ISD::InputArg &Arg) const;
640b57cec5SDimitry Andric   SDValue getPreloadedValue(SelectionDAG &DAG,
650b57cec5SDimitry Andric                             const SIMachineFunctionInfo &MFI,
660b57cec5SDimitry Andric                             EVT VT,
670b57cec5SDimitry Andric                             AMDGPUFunctionArgInfo::PreloadedValue) const;
680b57cec5SDimitry Andric 
690b57cec5SDimitry Andric   SDValue LowerGlobalAddress(AMDGPUMachineFunction *MFI, SDValue Op,
700b57cec5SDimitry Andric                              SelectionDAG &DAG) const override;
710b57cec5SDimitry Andric   SDValue lowerImplicitZextParam(SelectionDAG &DAG, SDValue Op,
720b57cec5SDimitry Andric                                  MVT VT, unsigned Offset) const;
730b57cec5SDimitry Andric   SDValue lowerImage(SDValue Op, const AMDGPU::ImageDimIntrinsicInfo *Intr,
74e8d8bef9SDimitry Andric                      SelectionDAG &DAG, bool WithChain) const;
750b57cec5SDimitry Andric   SDValue lowerSBuffer(EVT VT, SDLoc DL, SDValue Rsrc, SDValue Offset,
765ffd83dbSDimitry Andric                        SDValue CachePolicy, SelectionDAG &DAG) const;
770b57cec5SDimitry Andric 
78e8d8bef9SDimitry Andric   SDValue lowerRawBufferAtomicIntrin(SDValue Op, SelectionDAG &DAG,
79e8d8bef9SDimitry Andric                                      unsigned NewOpcode) const;
80e8d8bef9SDimitry Andric   SDValue lowerStructBufferAtomicIntrin(SDValue Op, SelectionDAG &DAG,
81e8d8bef9SDimitry Andric                                         unsigned NewOpcode) const;
82e8d8bef9SDimitry Andric 
83b3edf446SDimitry Andric   SDValue lowerWaveID(SelectionDAG &DAG, SDValue Op) const;
8481ad6265SDimitry Andric   SDValue lowerWorkitemID(SelectionDAG &DAG, SDValue Op, unsigned Dim,
8581ad6265SDimitry Andric                           const ArgDescriptor &ArgDesc) const;
8681ad6265SDimitry Andric 
870b57cec5SDimitry Andric   SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
880b57cec5SDimitry Andric   SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const;
890b57cec5SDimitry Andric   SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
900b57cec5SDimitry Andric 
910b57cec5SDimitry Andric   // The raw.tbuffer and struct.tbuffer intrinsics have two offset args: offset
920b57cec5SDimitry Andric   // (the offset that is included in bounds checking and swizzling, to be split
930b57cec5SDimitry Andric   // between the instruction's voffset and immoffset fields) and soffset (the
940b57cec5SDimitry Andric   // offset that is excluded from bounds checking and swizzling, to go in the
950b57cec5SDimitry Andric   // instruction's soffset field).  This function takes the first kind of
960b57cec5SDimitry Andric   // offset and figures out how to split it between voffset and immoffset.
970b57cec5SDimitry Andric   std::pair<SDValue, SDValue> splitBufferOffsets(SDValue Offset,
980b57cec5SDimitry Andric                                                  SelectionDAG &DAG) const;
990b57cec5SDimitry Andric 
1000b57cec5SDimitry Andric   SDValue widenLoad(LoadSDNode *Ld, DAGCombinerInfo &DCI) const;
1010b57cec5SDimitry Andric   SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
1020b57cec5SDimitry Andric   SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
1030b57cec5SDimitry Andric   SDValue lowerFastUnsafeFDIV(SDValue Op, SelectionDAG &DAG) const;
104e8d8bef9SDimitry Andric   SDValue lowerFastUnsafeFDIV64(SDValue Op, SelectionDAG &DAG) const;
1050b57cec5SDimitry Andric   SDValue lowerFDIV_FAST(SDValue Op, SelectionDAG &DAG) const;
1060b57cec5SDimitry Andric   SDValue LowerFDIV16(SDValue Op, SelectionDAG &DAG) const;
1070b57cec5SDimitry Andric   SDValue LowerFDIV32(SDValue Op, SelectionDAG &DAG) const;
1080b57cec5SDimitry Andric   SDValue LowerFDIV64(SDValue Op, SelectionDAG &DAG) const;
1090b57cec5SDimitry Andric   SDValue LowerFDIV(SDValue Op, SelectionDAG &DAG) const;
11006c3fb27SDimitry Andric   SDValue LowerFFREXP(SDValue Op, SelectionDAG &DAG) const;
1110b57cec5SDimitry Andric   SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
1120b57cec5SDimitry Andric   SDValue LowerTrig(SDValue Op, SelectionDAG &DAG) const;
1135f757f3fSDimitry Andric   SDValue lowerFSQRTF16(SDValue Op, SelectionDAG &DAG) const;
1145f757f3fSDimitry Andric   SDValue lowerFSQRTF32(SDValue Op, SelectionDAG &DAG) const;
11506c3fb27SDimitry Andric   SDValue lowerFSQRTF64(SDValue Op, SelectionDAG &DAG) const;
1160b57cec5SDimitry Andric   SDValue LowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const;
1170b57cec5SDimitry Andric   SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
1180b57cec5SDimitry Andric   SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
1190b57cec5SDimitry Andric   SDValue adjustLoadValueType(unsigned Opcode, MemSDNode *M,
1200b57cec5SDimitry Andric                               SelectionDAG &DAG, ArrayRef<SDValue> Ops,
1210b57cec5SDimitry Andric                               bool IsIntrinsic = false) const;
1220b57cec5SDimitry Andric 
1238bcb0991SDimitry Andric   SDValue lowerIntrinsicLoad(MemSDNode *M, bool IsFormat, SelectionDAG &DAG,
1248bcb0991SDimitry Andric                              ArrayRef<SDValue> Ops) const;
1258bcb0991SDimitry Andric 
1260b57cec5SDimitry Andric   // Call DAG.getMemIntrinsicNode for a load, but first widen a dwordx3 type to
1270b57cec5SDimitry Andric   // dwordx4 if on SI.
1280b57cec5SDimitry Andric   SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1290b57cec5SDimitry Andric                               ArrayRef<SDValue> Ops, EVT MemVT,
1300b57cec5SDimitry Andric                               MachineMemOperand *MMO, SelectionDAG &DAG) const;
1310b57cec5SDimitry Andric 
132e8d8bef9SDimitry Andric   SDValue handleD16VData(SDValue VData, SelectionDAG &DAG,
133e8d8bef9SDimitry Andric                          bool ImageStore = false) const;
1340b57cec5SDimitry Andric 
1350b57cec5SDimitry Andric   /// Converts \p Op, which must be of floating point type, to the
1360b57cec5SDimitry Andric   /// floating point type \p VT, by either extending or truncating it.
1375ffd83dbSDimitry Andric   SDValue getFPExtOrFPRound(SelectionDAG &DAG,
1380b57cec5SDimitry Andric                             SDValue Op,
1390b57cec5SDimitry Andric                             const SDLoc &DL,
1400b57cec5SDimitry Andric                             EVT VT) const;
1410b57cec5SDimitry Andric 
1420b57cec5SDimitry Andric   SDValue convertArgType(
1430b57cec5SDimitry Andric     SelectionDAG &DAG, EVT VT, EVT MemVT, const SDLoc &SL, SDValue Val,
1440b57cec5SDimitry Andric     bool Signed, const ISD::InputArg *Arg = nullptr) const;
1450b57cec5SDimitry Andric 
1460b57cec5SDimitry Andric   /// Custom lowering for ISD::FP_ROUND for MVT::f16.
1470b57cec5SDimitry Andric   SDValue lowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
1480b57cec5SDimitry Andric   SDValue lowerFMINNUM_FMAXNUM(SDValue Op, SelectionDAG &DAG) const;
14906c3fb27SDimitry Andric   SDValue lowerFLDEXP(SDValue Op, SelectionDAG &DAG) const;
1501db9f3b2SDimitry Andric   SDValue lowerMUL(SDValue Op, SelectionDAG &DAG) const;
1515ffd83dbSDimitry Andric   SDValue lowerXMULO(SDValue Op, SelectionDAG &DAG) const;
1524824e7fdSDimitry Andric   SDValue lowerXMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
1530b57cec5SDimitry Andric 
1540b57cec5SDimitry Andric   SDValue getSegmentAperture(unsigned AS, const SDLoc &DL,
1550b57cec5SDimitry Andric                              SelectionDAG &DAG) const;
1560b57cec5SDimitry Andric 
1570b57cec5SDimitry Andric   SDValue lowerADDRSPACECAST(SDValue Op, SelectionDAG &DAG) const;
1580b57cec5SDimitry Andric   SDValue lowerINSERT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
1590b57cec5SDimitry Andric   SDValue lowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
1600b57cec5SDimitry Andric   SDValue lowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
1610b57cec5SDimitry Andric   SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;
16281ad6265SDimitry Andric   SDValue lowerSCALAR_TO_VECTOR(SDValue Op, SelectionDAG &DAG) const;
1630b57cec5SDimitry Andric   SDValue lowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
164fe6060f1SDimitry Andric 
1650b57cec5SDimitry Andric   SDValue lowerTRAP(SDValue Op, SelectionDAG &DAG) const;
166fe6060f1SDimitry Andric   SDValue lowerTrapEndpgm(SDValue Op, SelectionDAG &DAG) const;
167fe6060f1SDimitry Andric   SDValue lowerTrapHsaQueuePtr(SDValue Op, SelectionDAG &DAG) const;
168fe6060f1SDimitry Andric   SDValue lowerTrapHsa(SDValue Op, SelectionDAG &DAG) const;
1690b57cec5SDimitry Andric   SDValue lowerDEBUGTRAP(SDValue Op, SelectionDAG &DAG) const;
1700b57cec5SDimitry Andric 
1710b57cec5SDimitry Andric   SDNode *adjustWritemask(MachineSDNode *&N, SelectionDAG &DAG) const;
1720b57cec5SDimitry Andric 
1730b57cec5SDimitry Andric   SDValue performUCharToFloatCombine(SDNode *N,
1740b57cec5SDimitry Andric                                      DAGCombinerInfo &DCI) const;
17506c3fb27SDimitry Andric   SDValue performFCopySignCombine(SDNode *N, DAGCombinerInfo &DCI) const;
17606c3fb27SDimitry Andric 
1770b57cec5SDimitry Andric   SDValue performSHLPtrCombine(SDNode *N,
1780b57cec5SDimitry Andric                                unsigned AS,
1790b57cec5SDimitry Andric                                EVT MemVT,
1800b57cec5SDimitry Andric                                DAGCombinerInfo &DCI) const;
1810b57cec5SDimitry Andric 
1820b57cec5SDimitry Andric   SDValue performMemSDNodeCombine(MemSDNode *N, DAGCombinerInfo &DCI) const;
1830b57cec5SDimitry Andric 
1840b57cec5SDimitry Andric   SDValue splitBinaryBitConstantOp(DAGCombinerInfo &DCI, const SDLoc &SL,
1850b57cec5SDimitry Andric                                    unsigned Opc, SDValue LHS,
1860b57cec5SDimitry Andric                                    const ConstantSDNode *CRHS) const;
1870b57cec5SDimitry Andric 
1880b57cec5SDimitry Andric   SDValue performAndCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1890b57cec5SDimitry Andric   SDValue performOrCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1900b57cec5SDimitry Andric   SDValue performXorCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1910b57cec5SDimitry Andric   SDValue performZeroExtendCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1920b57cec5SDimitry Andric   SDValue performSignExtendInRegCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1930b57cec5SDimitry Andric   SDValue performClassCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1940b57cec5SDimitry Andric   SDValue getCanonicalConstantFP(SelectionDAG &DAG, const SDLoc &SL, EVT VT,
1950b57cec5SDimitry Andric                                  const APFloat &C) const;
1960b57cec5SDimitry Andric   SDValue performFCanonicalizeCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1970b57cec5SDimitry Andric 
1980b57cec5SDimitry Andric   SDValue performFPMed3ImmCombine(SelectionDAG &DAG, const SDLoc &SL,
1990b57cec5SDimitry Andric                                   SDValue Op0, SDValue Op1) const;
2000b57cec5SDimitry Andric   SDValue performIntMed3ImmCombine(SelectionDAG &DAG, const SDLoc &SL,
20106c3fb27SDimitry Andric                                    SDValue Src, SDValue MinVal, SDValue MaxVal,
20206c3fb27SDimitry Andric                                    bool Signed) const;
2030b57cec5SDimitry Andric   SDValue performMinMaxCombine(SDNode *N, DAGCombinerInfo &DCI) const;
2040b57cec5SDimitry Andric   SDValue performFMed3Combine(SDNode *N, DAGCombinerInfo &DCI) const;
2050b57cec5SDimitry Andric   SDValue performCvtPkRTZCombine(SDNode *N, DAGCombinerInfo &DCI) const;
2060b57cec5SDimitry Andric   SDValue performExtractVectorEltCombine(SDNode *N, DAGCombinerInfo &DCI) const;
2070b57cec5SDimitry Andric   SDValue performInsertVectorEltCombine(SDNode *N, DAGCombinerInfo &DCI) const;
20806c3fb27SDimitry Andric   SDValue performFPRoundCombine(SDNode *N, DAGCombinerInfo &DCI) const;
2090b57cec5SDimitry Andric 
2100b57cec5SDimitry Andric   SDValue reassociateScalarOps(SDNode *N, SelectionDAG &DAG) const;
2110b57cec5SDimitry Andric   unsigned getFusedOpcode(const SelectionDAG &DAG,
2120b57cec5SDimitry Andric                           const SDNode *N0, const SDNode *N1) const;
21381ad6265SDimitry Andric   SDValue tryFoldToMad64_32(SDNode *N, DAGCombinerInfo &DCI) const;
2140b57cec5SDimitry Andric   SDValue performAddCombine(SDNode *N, DAGCombinerInfo &DCI) const;
2150b57cec5SDimitry Andric   SDValue performAddCarrySubCarryCombine(SDNode *N, DAGCombinerInfo &DCI) const;
2160b57cec5SDimitry Andric   SDValue performSubCombine(SDNode *N, DAGCombinerInfo &DCI) const;
2170b57cec5SDimitry Andric   SDValue performFAddCombine(SDNode *N, DAGCombinerInfo &DCI) const;
2180b57cec5SDimitry Andric   SDValue performFSubCombine(SDNode *N, DAGCombinerInfo &DCI) const;
2195f757f3fSDimitry Andric   SDValue performFDivCombine(SDNode *N, DAGCombinerInfo &DCI) const;
2200b57cec5SDimitry Andric   SDValue performFMACombine(SDNode *N, DAGCombinerInfo &DCI) const;
2210b57cec5SDimitry Andric   SDValue performSetCCCombine(SDNode *N, DAGCombinerInfo &DCI) const;
2220b57cec5SDimitry Andric   SDValue performCvtF32UByteNCombine(SDNode *N, DAGCombinerInfo &DCI) const;
2230b57cec5SDimitry Andric   SDValue performClampCombine(SDNode *N, DAGCombinerInfo &DCI) const;
2240b57cec5SDimitry Andric   SDValue performRcpCombine(SDNode *N, DAGCombinerInfo &DCI) const;
2250b57cec5SDimitry Andric 
2260b57cec5SDimitry Andric   bool isLegalMUBUFAddressingMode(const AddrMode &AM) const;
2270b57cec5SDimitry Andric 
2280b57cec5SDimitry Andric   unsigned isCFIntrinsic(const SDNode *Intr) const;
2290b57cec5SDimitry Andric 
2308bcb0991SDimitry Andric public:
2310b57cec5SDimitry Andric   /// \returns True if fixup needs to be emitted for given global value \p GV,
2320b57cec5SDimitry Andric   /// false otherwise.
2330b57cec5SDimitry Andric   bool shouldEmitFixup(const GlobalValue *GV) const;
2340b57cec5SDimitry Andric 
2350b57cec5SDimitry Andric   /// \returns True if GOT relocation needs to be emitted for given global value
2360b57cec5SDimitry Andric   /// \p GV, false otherwise.
2370b57cec5SDimitry Andric   bool shouldEmitGOTReloc(const GlobalValue *GV) const;
2380b57cec5SDimitry Andric 
2390b57cec5SDimitry Andric   /// \returns True if PC-relative relocation needs to be emitted for given
2400b57cec5SDimitry Andric   /// global value \p GV, false otherwise.
2410b57cec5SDimitry Andric   bool shouldEmitPCReloc(const GlobalValue *GV) const;
2420b57cec5SDimitry Andric 
2435ffd83dbSDimitry Andric   /// \returns true if this should use a literal constant for an LDS address,
2445ffd83dbSDimitry Andric   /// and not emit a relocation for an LDS global.
2455ffd83dbSDimitry Andric   bool shouldUseLDSConstAddress(const GlobalValue *GV) const;
2465ffd83dbSDimitry Andric 
2475ffd83dbSDimitry Andric   /// Check if EXTRACT_VECTOR_ELT/INSERT_VECTOR_ELT (<n x e>, var-idx) should be
2485ffd83dbSDimitry Andric   /// expanded into a set of cmp/select instructions.
2495ffd83dbSDimitry Andric   static bool shouldExpandVectorDynExt(unsigned EltSize, unsigned NumElem,
25081ad6265SDimitry Andric                                        bool IsDivergentIdx,
25181ad6265SDimitry Andric                                        const GCNSubtarget *Subtarget);
25281ad6265SDimitry Andric 
25381ad6265SDimitry Andric   bool shouldExpandVectorDynExt(SDNode *N) const;
2545ffd83dbSDimitry Andric 
2558bcb0991SDimitry Andric private:
256*0fca6ea1SDimitry Andric   // Analyze a combined offset from an amdgcn_s_buffer_load intrinsic and store
257*0fca6ea1SDimitry Andric   // the three offsets (voffset, soffset and instoffset) into the SDValue[3]
258*0fca6ea1SDimitry Andric   // array pointed to by Offsets.
259fe6060f1SDimitry Andric   void setBufferOffsets(SDValue CombinedOffset, SelectionDAG &DAG,
2605ffd83dbSDimitry Andric                         SDValue *Offsets, Align Alignment = Align(4)) const;
2610b57cec5SDimitry Andric 
26206c3fb27SDimitry Andric   // Convert the i128 that an addrspace(8) pointer is natively represented as
26306c3fb27SDimitry Andric   // into the v4i32 that all the buffer intrinsics expect to receive. We can't
26406c3fb27SDimitry Andric   // add register classes for i128 on pain of the promotion logic going haywire,
26506c3fb27SDimitry Andric   // so this slightly ugly hack is what we've got. If passed a non-pointer
26606c3fb27SDimitry Andric   // argument (as would be seen in older buffer intrinsics), does nothing.
26706c3fb27SDimitry Andric   SDValue bufferRsrcPtrToVector(SDValue MaybePointer, SelectionDAG &DAG) const;
26806c3fb27SDimitry Andric 
26906c3fb27SDimitry Andric   // Wrap a 64-bit pointer into a v4i32 (which is how all SelectionDAG code
27006c3fb27SDimitry Andric   // represents ptr addrspace(8)) using the flags specified in the intrinsic.
27106c3fb27SDimitry Andric   SDValue lowerPointerAsRsrcIntrin(SDNode *Op, SelectionDAG &DAG) const;
27206c3fb27SDimitry Andric 
2730b57cec5SDimitry Andric   // Handle 8 bit and 16 bit buffer loads
2740b57cec5SDimitry Andric   SDValue handleByteShortBufferLoads(SelectionDAG &DAG, EVT LoadVT, SDLoc DL,
2757a6dacacSDimitry Andric                                      ArrayRef<SDValue> Ops,
276*0fca6ea1SDimitry Andric                                      MachineMemOperand *MMO,
277*0fca6ea1SDimitry Andric                                      bool IsTFE = false) const;
2780b57cec5SDimitry Andric 
2790b57cec5SDimitry Andric   // Handle 8 bit and 16 bit buffer stores
2800b57cec5SDimitry Andric   SDValue handleByteShortBufferStores(SelectionDAG &DAG, EVT VDataType,
2810b57cec5SDimitry Andric                                       SDLoc DL, SDValue Ops[],
2820b57cec5SDimitry Andric                                       MemSDNode *M) const;
2830b57cec5SDimitry Andric 
2840b57cec5SDimitry Andric public:
2850b57cec5SDimitry Andric   SITargetLowering(const TargetMachine &tm, const GCNSubtarget &STI);
2860b57cec5SDimitry Andric 
2870b57cec5SDimitry Andric   const GCNSubtarget *getSubtarget() const;
2880b57cec5SDimitry Andric 
289*0fca6ea1SDimitry Andric   ArrayRef<MCPhysReg> getRoundingControlRegisters() const override;
290*0fca6ea1SDimitry Andric 
291480093f4SDimitry Andric   bool isFPExtFoldable(const SelectionDAG &DAG, unsigned Opcode, EVT DestVT,
292480093f4SDimitry Andric                        EVT SrcVT) const override;
2930b57cec5SDimitry Andric 
2944824e7fdSDimitry Andric   bool isFPExtFoldable(const MachineInstr &MI, unsigned Opcode, LLT DestTy,
2954824e7fdSDimitry Andric                        LLT SrcTy) const override;
2964824e7fdSDimitry Andric 
2970b57cec5SDimitry Andric   bool isShuffleMaskLegal(ArrayRef<int> /*Mask*/, EVT /*VT*/) const override;
2980b57cec5SDimitry Andric 
29906c3fb27SDimitry Andric   // While address space 7 should never make it to codegen, it still needs to
30006c3fb27SDimitry Andric   // have a MVT to prevent some analyses that query this function from breaking,
30106c3fb27SDimitry Andric   // so, to work around the lack of i160, map it to v5i32.
30206c3fb27SDimitry Andric   MVT getPointerTy(const DataLayout &DL, unsigned AS) const override;
30306c3fb27SDimitry Andric   MVT getPointerMemTy(const DataLayout &DL, unsigned AS) const override;
30406c3fb27SDimitry Andric 
3050b57cec5SDimitry Andric   bool getTgtMemIntrinsic(IntrinsicInfo &, const CallInst &,
3060b57cec5SDimitry Andric                           MachineFunction &MF,
3070b57cec5SDimitry Andric                           unsigned IntrinsicID) const override;
3080b57cec5SDimitry Andric 
309*0fca6ea1SDimitry Andric   void CollectTargetIntrinsicOperands(const CallInst &I,
310*0fca6ea1SDimitry Andric                                       SmallVectorImpl<SDValue> &Ops,
311*0fca6ea1SDimitry Andric                                       SelectionDAG &DAG) const override;
312*0fca6ea1SDimitry Andric 
3130b57cec5SDimitry Andric   bool getAddrModeArguments(IntrinsicInst * /*I*/,
3140b57cec5SDimitry Andric                             SmallVectorImpl<Value*> &/*Ops*/,
3150b57cec5SDimitry Andric                             Type *&/*AccessTy*/) const override;
3160b57cec5SDimitry Andric 
317*0fca6ea1SDimitry Andric   bool isLegalFlatAddressingMode(const AddrMode &AM, unsigned AddrSpace) const;
3180b57cec5SDimitry Andric   bool isLegalGlobalAddressingMode(const AddrMode &AM) const;
3190b57cec5SDimitry Andric   bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
3200b57cec5SDimitry Andric                              unsigned AS,
3210b57cec5SDimitry Andric                              Instruction *I = nullptr) const override;
3220b57cec5SDimitry Andric 
3230b57cec5SDimitry Andric   bool canMergeStoresTo(unsigned AS, EVT MemVT,
324349cc55cSDimitry Andric                         const MachineFunction &MF) const override;
3250b57cec5SDimitry Andric 
3268bcb0991SDimitry Andric   bool allowsMisalignedMemoryAccessesImpl(
327e8d8bef9SDimitry Andric       unsigned Size, unsigned AddrSpace, Align Alignment,
3288bcb0991SDimitry Andric       MachineMemOperand::Flags Flags = MachineMemOperand::MONone,
329bdd1243dSDimitry Andric       unsigned *IsFast = nullptr) const;
3308bcb0991SDimitry Andric 
3310b57cec5SDimitry Andric   bool allowsMisalignedMemoryAccesses(
332e8d8bef9SDimitry Andric       LLT Ty, unsigned AddrSpace, Align Alignment,
333e8d8bef9SDimitry Andric       MachineMemOperand::Flags Flags = MachineMemOperand::MONone,
334bdd1243dSDimitry Andric       unsigned *IsFast = nullptr) const override {
335e8d8bef9SDimitry Andric     if (IsFast)
336bdd1243dSDimitry Andric       *IsFast = 0;
337e8d8bef9SDimitry Andric     return allowsMisalignedMemoryAccessesImpl(Ty.getSizeInBits(), AddrSpace,
338e8d8bef9SDimitry Andric                                               Alignment, Flags, IsFast);
339e8d8bef9SDimitry Andric   }
340e8d8bef9SDimitry Andric 
341e8d8bef9SDimitry Andric   bool allowsMisalignedMemoryAccesses(
342fe6060f1SDimitry Andric       EVT VT, unsigned AS, Align Alignment,
3430b57cec5SDimitry Andric       MachineMemOperand::Flags Flags = MachineMemOperand::MONone,
344bdd1243dSDimitry Andric       unsigned *IsFast = nullptr) const override;
3450b57cec5SDimitry Andric 
3465ffd83dbSDimitry Andric   EVT getOptimalMemOpType(const MemOp &Op,
3470b57cec5SDimitry Andric                           const AttributeList &FuncAttributes) const override;
3480b57cec5SDimitry Andric 
3490b57cec5SDimitry Andric   bool isMemOpUniform(const SDNode *N) const;
3500b57cec5SDimitry Andric   bool isMemOpHasNoClobberedMemOperand(const SDNode *N) const;
351480093f4SDimitry Andric 
352e8d8bef9SDimitry Andric   static bool isNonGlobalAddrSpace(unsigned AS);
3535ffd83dbSDimitry Andric 
3540b57cec5SDimitry Andric   bool isFreeAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override;
3550b57cec5SDimitry Andric 
3560b57cec5SDimitry Andric   TargetLoweringBase::LegalizeTypeAction
3570b57cec5SDimitry Andric   getPreferredVectorAction(MVT VT) const override;
3580b57cec5SDimitry Andric 
3590b57cec5SDimitry Andric   bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
3600b57cec5SDimitry Andric                                         Type *Ty) const override;
3610b57cec5SDimitry Andric 
36281ad6265SDimitry Andric   bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
36381ad6265SDimitry Andric                                unsigned Index) const override;
36481ad6265SDimitry Andric 
3650b57cec5SDimitry Andric   bool isTypeDesirableForOp(unsigned Op, EVT VT) const override;
3660b57cec5SDimitry Andric 
3670b57cec5SDimitry Andric   bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
3680b57cec5SDimitry Andric 
combineRepeatedFPDivisors()36906c3fb27SDimitry Andric   unsigned combineRepeatedFPDivisors() const override {
37006c3fb27SDimitry Andric     // Combine multiple FDIVs with the same divisor into multiple FMULs by the
37106c3fb27SDimitry Andric     // reciprocal.
37206c3fb27SDimitry Andric     return 2;
37306c3fb27SDimitry Andric   }
37406c3fb27SDimitry Andric 
3750b57cec5SDimitry Andric   bool supportSplitCSR(MachineFunction *MF) const override;
3760b57cec5SDimitry Andric   void initializeSplitCSR(MachineBasicBlock *Entry) const override;
3770b57cec5SDimitry Andric   void insertCopiesSplitCSR(
3780b57cec5SDimitry Andric     MachineBasicBlock *Entry,
3790b57cec5SDimitry Andric     const SmallVectorImpl<MachineBasicBlock *> &Exits) const override;
3800b57cec5SDimitry Andric 
3810b57cec5SDimitry Andric   SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
3820b57cec5SDimitry Andric                                bool isVarArg,
3830b57cec5SDimitry Andric                                const SmallVectorImpl<ISD::InputArg> &Ins,
3840b57cec5SDimitry Andric                                const SDLoc &DL, SelectionDAG &DAG,
3850b57cec5SDimitry Andric                                SmallVectorImpl<SDValue> &InVals) const override;
3860b57cec5SDimitry Andric 
3870b57cec5SDimitry Andric   bool CanLowerReturn(CallingConv::ID CallConv,
3880b57cec5SDimitry Andric                       MachineFunction &MF, bool isVarArg,
3890b57cec5SDimitry Andric                       const SmallVectorImpl<ISD::OutputArg> &Outs,
3900b57cec5SDimitry Andric                       LLVMContext &Context) const override;
3910b57cec5SDimitry Andric 
3920b57cec5SDimitry Andric   SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
3930b57cec5SDimitry Andric                       const SmallVectorImpl<ISD::OutputArg> &Outs,
3940b57cec5SDimitry Andric                       const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
3950b57cec5SDimitry Andric                       SelectionDAG &DAG) const override;
3960b57cec5SDimitry Andric 
3970b57cec5SDimitry Andric   void passSpecialInputs(
3980b57cec5SDimitry Andric     CallLoweringInfo &CLI,
3990b57cec5SDimitry Andric     CCState &CCInfo,
4000b57cec5SDimitry Andric     const SIMachineFunctionInfo &Info,
4010b57cec5SDimitry Andric     SmallVectorImpl<std::pair<unsigned, SDValue>> &RegsToPass,
4020b57cec5SDimitry Andric     SmallVectorImpl<SDValue> &MemOpChains,
4030b57cec5SDimitry Andric     SDValue Chain) const;
4040b57cec5SDimitry Andric 
40506c3fb27SDimitry Andric   SDValue LowerCallResult(SDValue Chain, SDValue InGlue,
4060b57cec5SDimitry Andric                           CallingConv::ID CallConv, bool isVarArg,
4070b57cec5SDimitry Andric                           const SmallVectorImpl<ISD::InputArg> &Ins,
4080b57cec5SDimitry Andric                           const SDLoc &DL, SelectionDAG &DAG,
4090b57cec5SDimitry Andric                           SmallVectorImpl<SDValue> &InVals, bool isThisReturn,
4100b57cec5SDimitry Andric                           SDValue ThisVal) const;
4110b57cec5SDimitry Andric 
4120b57cec5SDimitry Andric   bool mayBeEmittedAsTailCall(const CallInst *) const override;
4130b57cec5SDimitry Andric 
4140b57cec5SDimitry Andric   bool isEligibleForTailCallOptimization(
4150b57cec5SDimitry Andric     SDValue Callee, CallingConv::ID CalleeCC, bool isVarArg,
4160b57cec5SDimitry Andric     const SmallVectorImpl<ISD::OutputArg> &Outs,
4170b57cec5SDimitry Andric     const SmallVectorImpl<SDValue> &OutVals,
4180b57cec5SDimitry Andric     const SmallVectorImpl<ISD::InputArg> &Ins, SelectionDAG &DAG) const;
4190b57cec5SDimitry Andric 
4200b57cec5SDimitry Andric   SDValue LowerCall(CallLoweringInfo &CLI,
4210b57cec5SDimitry Andric                     SmallVectorImpl<SDValue> &InVals) const override;
4220b57cec5SDimitry Andric 
4235ffd83dbSDimitry Andric   SDValue lowerDYNAMIC_STACKALLOCImpl(SDValue Op, SelectionDAG &DAG) const;
4245ffd83dbSDimitry Andric   SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
4255f757f3fSDimitry Andric   SDValue LowerSTACKSAVE(SDValue Op, SelectionDAG &DAG) const;
4265f757f3fSDimitry Andric   SDValue lowerGET_ROUNDING(SDValue Op, SelectionDAG &DAG) const;
427*0fca6ea1SDimitry Andric   SDValue lowerSET_ROUNDING(SDValue Op, SelectionDAG &DAG) const;
4285f757f3fSDimitry Andric 
4295f757f3fSDimitry Andric   SDValue lowerPREFETCH(SDValue Op, SelectionDAG &DAG) const;
4301db9f3b2SDimitry Andric   SDValue lowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const;
431*0fca6ea1SDimitry Andric   SDValue lowerGET_FPENV(SDValue Op, SelectionDAG &DAG) const;
432*0fca6ea1SDimitry Andric   SDValue lowerSET_FPENV(SDValue Op, SelectionDAG &DAG) const;
4335ffd83dbSDimitry Andric 
434480093f4SDimitry Andric   Register getRegisterByName(const char* RegName, LLT VT,
4358bcb0991SDimitry Andric                              const MachineFunction &MF) const override;
4360b57cec5SDimitry Andric 
4370b57cec5SDimitry Andric   MachineBasicBlock *splitKillBlock(MachineInstr &MI,
4380b57cec5SDimitry Andric                                     MachineBasicBlock *BB) const;
4390b57cec5SDimitry Andric 
4408bcb0991SDimitry Andric   void bundleInstWithWaitcnt(MachineInstr &MI) const;
4410b57cec5SDimitry Andric   MachineBasicBlock *emitGWSMemViolTestLoop(MachineInstr &MI,
4420b57cec5SDimitry Andric                                             MachineBasicBlock *BB) const;
4430b57cec5SDimitry Andric 
4440b57cec5SDimitry Andric   MachineBasicBlock *
4450b57cec5SDimitry Andric   EmitInstrWithCustomInserter(MachineInstr &MI,
4460b57cec5SDimitry Andric                               MachineBasicBlock *BB) const override;
4470b57cec5SDimitry Andric 
4480b57cec5SDimitry Andric   bool enableAggressiveFMAFusion(EVT VT) const override;
4494824e7fdSDimitry Andric   bool enableAggressiveFMAFusion(LLT Ty) const override;
4500b57cec5SDimitry Andric   EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
4510b57cec5SDimitry Andric                          EVT VT) const override;
4520b57cec5SDimitry Andric   MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override;
453e8d8bef9SDimitry Andric   LLT getPreferredShiftAmountTy(LLT Ty) const override;
454e8d8bef9SDimitry Andric 
455480093f4SDimitry Andric   bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
456480093f4SDimitry Andric                                   EVT VT) const override;
4574824e7fdSDimitry Andric   bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
4584824e7fdSDimitry Andric                                   const LLT Ty) const override;
4595ffd83dbSDimitry Andric   bool isFMADLegal(const SelectionDAG &DAG, const SDNode *N) const override;
4604824e7fdSDimitry Andric   bool isFMADLegal(const MachineInstr &MI, const LLT Ty) const override;
461480093f4SDimitry Andric 
4620b57cec5SDimitry Andric   SDValue splitUnaryVectorOp(SDValue Op, SelectionDAG &DAG) const;
4630b57cec5SDimitry Andric   SDValue splitBinaryVectorOp(SDValue Op, SelectionDAG &DAG) const;
4648bcb0991SDimitry Andric   SDValue splitTernaryVectorOp(SDValue Op, SelectionDAG &DAG) const;
4650b57cec5SDimitry Andric   SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
4660b57cec5SDimitry Andric 
4670b57cec5SDimitry Andric   void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
4680b57cec5SDimitry Andric                           SelectionDAG &DAG) const override;
4690b57cec5SDimitry Andric 
4700b57cec5SDimitry Andric   SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
4710b57cec5SDimitry Andric   SDNode *PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const override;
472*0fca6ea1SDimitry Andric   void AddMemOpInit(MachineInstr &MI) const;
4730b57cec5SDimitry Andric   void AdjustInstrPostInstrSelection(MachineInstr &MI,
4740b57cec5SDimitry Andric                                      SDNode *Node) const override;
4750b57cec5SDimitry Andric 
4760b57cec5SDimitry Andric   SDNode *legalizeTargetIndependentNode(SDNode *Node, SelectionDAG &DAG) const;
4770b57cec5SDimitry Andric 
4780b57cec5SDimitry Andric   MachineSDNode *wrapAddr64Rsrc(SelectionDAG &DAG, const SDLoc &DL,
4790b57cec5SDimitry Andric                                 SDValue Ptr) const;
4800b57cec5SDimitry Andric   MachineSDNode *buildRSRC(SelectionDAG &DAG, const SDLoc &DL, SDValue Ptr,
4810b57cec5SDimitry Andric                            uint32_t RsrcDword1, uint64_t RsrcDword2And3) const;
4820b57cec5SDimitry Andric   std::pair<unsigned, const TargetRegisterClass *>
4830b57cec5SDimitry Andric   getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
4840b57cec5SDimitry Andric                                StringRef Constraint, MVT VT) const override;
4850b57cec5SDimitry Andric   ConstraintType getConstraintType(StringRef Constraint) const override;
4865f757f3fSDimitry Andric   void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint,
4875ffd83dbSDimitry Andric                                     std::vector<SDValue> &Ops,
4885ffd83dbSDimitry Andric                                     SelectionDAG &DAG) const override;
4895ffd83dbSDimitry Andric   bool getAsmOperandConstVal(SDValue Op, uint64_t &Val) const;
4905f757f3fSDimitry Andric   bool checkAsmConstraintVal(SDValue Op, StringRef Constraint,
4915ffd83dbSDimitry Andric                              uint64_t Val) const;
4925ffd83dbSDimitry Andric   bool checkAsmConstraintValA(SDValue Op,
4935ffd83dbSDimitry Andric                               uint64_t Val,
4945ffd83dbSDimitry Andric                               unsigned MaxSize = 64) const;
4950b57cec5SDimitry Andric   SDValue copyToM0(SelectionDAG &DAG, SDValue Chain, const SDLoc &DL,
4960b57cec5SDimitry Andric                    SDValue V) const;
4970b57cec5SDimitry Andric 
4980b57cec5SDimitry Andric   void finalizeLowering(MachineFunction &MF) const override;
4990b57cec5SDimitry Andric 
50006c3fb27SDimitry Andric   void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known,
50106c3fb27SDimitry Andric                                      const APInt &DemandedElts,
50206c3fb27SDimitry Andric                                      const SelectionDAG &DAG,
50306c3fb27SDimitry Andric                                      unsigned Depth = 0) const override;
5045ffd83dbSDimitry Andric   void computeKnownBitsForFrameIndex(int FrameIdx,
5050b57cec5SDimitry Andric                                      KnownBits &Known,
5065ffd83dbSDimitry Andric                                      const MachineFunction &MF) const override;
507e8d8bef9SDimitry Andric   void computeKnownBitsForTargetInstr(GISelKnownBits &Analysis, Register R,
508e8d8bef9SDimitry Andric                                       KnownBits &Known,
509e8d8bef9SDimitry Andric                                       const APInt &DemandedElts,
510e8d8bef9SDimitry Andric                                       const MachineRegisterInfo &MRI,
511e8d8bef9SDimitry Andric                                       unsigned Depth = 0) const override;
5120b57cec5SDimitry Andric 
5135ffd83dbSDimitry Andric   Align computeKnownAlignForTargetInstr(GISelKnownBits &Analysis, Register R,
5145ffd83dbSDimitry Andric                                         const MachineRegisterInfo &MRI,
5155ffd83dbSDimitry Andric                                         unsigned Depth = 0) const override;
51606c3fb27SDimitry Andric   bool isSDNodeSourceOfDivergence(const SDNode *N, FunctionLoweringInfo *FLI,
51706c3fb27SDimitry Andric                                   UniformityInfo *UA) const override;
5180b57cec5SDimitry Andric 
51904eeddc0SDimitry Andric   bool hasMemSDNodeUser(SDNode *N) const;
52004eeddc0SDimitry Andric 
52104eeddc0SDimitry Andric   bool isReassocProfitable(SelectionDAG &DAG, SDValue N0,
52204eeddc0SDimitry Andric                            SDValue N1) const override;
52304eeddc0SDimitry Andric 
52406c3fb27SDimitry Andric   bool isReassocProfitable(MachineRegisterInfo &MRI, Register N0,
52506c3fb27SDimitry Andric                            Register N1) const override;
52606c3fb27SDimitry Andric 
5270b57cec5SDimitry Andric   bool isCanonicalized(SelectionDAG &DAG, SDValue Op,
5280b57cec5SDimitry Andric                        unsigned MaxDepth = 5) const;
529*0fca6ea1SDimitry Andric   bool isCanonicalized(Register Reg, const MachineFunction &MF,
530fe6060f1SDimitry Andric                        unsigned MaxDepth = 5) const;
531480093f4SDimitry Andric   bool denormalsEnabledForType(const SelectionDAG &DAG, EVT VT) const;
532*0fca6ea1SDimitry Andric   bool denormalsEnabledForType(LLT Ty, const MachineFunction &MF) const;
5330b57cec5SDimitry Andric 
534bdd1243dSDimitry Andric   bool checkForPhysRegDependency(SDNode *Def, SDNode *User, unsigned Op,
535bdd1243dSDimitry Andric                                  const TargetRegisterInfo *TRI,
536bdd1243dSDimitry Andric                                  const TargetInstrInfo *TII, unsigned &PhysReg,
537bdd1243dSDimitry Andric                                  int &Cost) const override;
538bdd1243dSDimitry Andric 
5390b57cec5SDimitry Andric   bool isKnownNeverNaNForTargetNode(SDValue Op,
5400b57cec5SDimitry Andric                                     const SelectionDAG &DAG,
5410b57cec5SDimitry Andric                                     bool SNaN = false,
5420b57cec5SDimitry Andric                                     unsigned Depth = 0) const override;
5430b57cec5SDimitry Andric   AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *) const override;
54481ad6265SDimitry Andric   AtomicExpansionKind shouldExpandAtomicLoadInIR(LoadInst *LI) const override;
54581ad6265SDimitry Andric   AtomicExpansionKind shouldExpandAtomicStoreInIR(StoreInst *SI) const override;
54681ad6265SDimitry Andric   AtomicExpansionKind
54781ad6265SDimitry Andric   shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
548bdd1243dSDimitry Andric   void emitExpandAtomicRMW(AtomicRMWInst *AI) const override;
5490b57cec5SDimitry Andric 
55006c3fb27SDimitry Andric   LoadInst *
55106c3fb27SDimitry Andric   lowerIdempotentRMWIntoFencedLoad(AtomicRMWInst *AI) const override;
55206c3fb27SDimitry Andric 
553972a253aSDimitry Andric   const TargetRegisterClass *getRegClassFor(MVT VT,
554972a253aSDimitry Andric                                             bool isDivergent) const override;
555972a253aSDimitry Andric   bool requiresUniformRegister(MachineFunction &MF,
5568bcb0991SDimitry Andric                                const Value *V) const override;
5578bcb0991SDimitry Andric   Align getPrefLoopAlignment(MachineLoop *ML) const override;
5588bcb0991SDimitry Andric 
5598bcb0991SDimitry Andric   void allocateHSAUserSGPRs(CCState &CCInfo,
5608bcb0991SDimitry Andric                             MachineFunction &MF,
5618bcb0991SDimitry Andric                             const SIRegisterInfo &TRI,
5628bcb0991SDimitry Andric                             SIMachineFunctionInfo &Info) const;
5638bcb0991SDimitry Andric 
5645f757f3fSDimitry Andric   void allocatePreloadKernArgSGPRs(CCState &CCInfo,
5655f757f3fSDimitry Andric                                    SmallVectorImpl<CCValAssign> &ArgLocs,
5665f757f3fSDimitry Andric                                    const SmallVectorImpl<ISD::InputArg> &Ins,
5675f757f3fSDimitry Andric                                    MachineFunction &MF,
5685f757f3fSDimitry Andric                                    const SIRegisterInfo &TRI,
5695f757f3fSDimitry Andric                                    SIMachineFunctionInfo &Info) const;
5705f757f3fSDimitry Andric 
5715f757f3fSDimitry Andric   void allocateLDSKernelId(CCState &CCInfo, MachineFunction &MF,
5725f757f3fSDimitry Andric                            const SIRegisterInfo &TRI,
5735f757f3fSDimitry Andric                            SIMachineFunctionInfo &Info) const;
5745f757f3fSDimitry Andric 
5758bcb0991SDimitry Andric   void allocateSystemSGPRs(CCState &CCInfo,
5768bcb0991SDimitry Andric                            MachineFunction &MF,
5778bcb0991SDimitry Andric                            SIMachineFunctionInfo &Info,
5788bcb0991SDimitry Andric                            CallingConv::ID CallConv,
5798bcb0991SDimitry Andric                            bool IsShader) const;
5808bcb0991SDimitry Andric 
5818bcb0991SDimitry Andric   void allocateSpecialEntryInputVGPRs(CCState &CCInfo,
5828bcb0991SDimitry Andric                                       MachineFunction &MF,
5838bcb0991SDimitry Andric                                       const SIRegisterInfo &TRI,
5848bcb0991SDimitry Andric                                       SIMachineFunctionInfo &Info) const;
5858bcb0991SDimitry Andric   void allocateSpecialInputSGPRs(
5868bcb0991SDimitry Andric     CCState &CCInfo,
5878bcb0991SDimitry Andric     MachineFunction &MF,
5888bcb0991SDimitry Andric     const SIRegisterInfo &TRI,
5898bcb0991SDimitry Andric     SIMachineFunctionInfo &Info) const;
5908bcb0991SDimitry Andric 
5918bcb0991SDimitry Andric   void allocateSpecialInputVGPRs(CCState &CCInfo,
5928bcb0991SDimitry Andric                                  MachineFunction &MF,
5938bcb0991SDimitry Andric                                  const SIRegisterInfo &TRI,
5948bcb0991SDimitry Andric                                  SIMachineFunctionInfo &Info) const;
5955ffd83dbSDimitry Andric   void allocateSpecialInputVGPRsFixed(CCState &CCInfo,
5965ffd83dbSDimitry Andric                                       MachineFunction &MF,
5975ffd83dbSDimitry Andric                                       const SIRegisterInfo &TRI,
5985ffd83dbSDimitry Andric                                       SIMachineFunctionInfo &Info) const;
5995ffd83dbSDimitry Andric 
60081ad6265SDimitry Andric   MachineMemOperand::Flags
60181ad6265SDimitry Andric   getTargetMMOFlags(const Instruction &I) const override;
6020b57cec5SDimitry Andric };
6030b57cec5SDimitry Andric 
6045f757f3fSDimitry Andric // Returns true if argument is a boolean value which is not serialized into
6055f757f3fSDimitry Andric // memory or argument and does not require v_cndmask_b32 to be deserialized.
6065f757f3fSDimitry Andric bool isBoolSGPR(SDValue V);
6075f757f3fSDimitry Andric 
6080b57cec5SDimitry Andric } // End namespace llvm
6090b57cec5SDimitry Andric 
6100b57cec5SDimitry Andric #endif
611