xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/SIISelLowering.h (revision 480093f4440d54b30b3025afeac24b48f2ba7a2e)
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"
190b57cec5SDimitry Andric #include "SIInstrInfo.h"
200b57cec5SDimitry Andric 
210b57cec5SDimitry Andric namespace llvm {
220b57cec5SDimitry Andric 
230b57cec5SDimitry Andric class SITargetLowering final : public AMDGPUTargetLowering {
240b57cec5SDimitry Andric private:
250b57cec5SDimitry Andric   const GCNSubtarget *Subtarget;
260b57cec5SDimitry Andric 
270b57cec5SDimitry Andric public:
280b57cec5SDimitry Andric   MVT getRegisterTypeForCallingConv(LLVMContext &Context,
290b57cec5SDimitry Andric                                     CallingConv::ID CC,
300b57cec5SDimitry Andric                                     EVT VT) const override;
310b57cec5SDimitry Andric   unsigned getNumRegistersForCallingConv(LLVMContext &Context,
320b57cec5SDimitry Andric                                          CallingConv::ID CC,
330b57cec5SDimitry Andric                                          EVT VT) const override;
340b57cec5SDimitry Andric 
350b57cec5SDimitry Andric   unsigned getVectorTypeBreakdownForCallingConv(
360b57cec5SDimitry Andric     LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT,
370b57cec5SDimitry Andric     unsigned &NumIntermediates, MVT &RegisterVT) const override;
380b57cec5SDimitry Andric 
390b57cec5SDimitry Andric private:
400b57cec5SDimitry Andric   SDValue lowerKernArgParameterPtr(SelectionDAG &DAG, const SDLoc &SL,
410b57cec5SDimitry Andric                                    SDValue Chain, uint64_t Offset) const;
420b57cec5SDimitry Andric   SDValue getImplicitArgPtr(SelectionDAG &DAG, const SDLoc &SL) const;
430b57cec5SDimitry Andric   SDValue lowerKernargMemParameter(SelectionDAG &DAG, EVT VT, EVT MemVT,
440b57cec5SDimitry Andric                                    const SDLoc &SL, SDValue Chain,
450b57cec5SDimitry Andric                                    uint64_t Offset, unsigned Align, bool Signed,
460b57cec5SDimitry Andric                                    const ISD::InputArg *Arg = nullptr) const;
470b57cec5SDimitry Andric 
480b57cec5SDimitry Andric   SDValue lowerStackParameter(SelectionDAG &DAG, CCValAssign &VA,
490b57cec5SDimitry Andric                               const SDLoc &SL, SDValue Chain,
500b57cec5SDimitry Andric                               const ISD::InputArg &Arg) const;
510b57cec5SDimitry Andric   SDValue getPreloadedValue(SelectionDAG &DAG,
520b57cec5SDimitry Andric                             const SIMachineFunctionInfo &MFI,
530b57cec5SDimitry Andric                             EVT VT,
540b57cec5SDimitry Andric                             AMDGPUFunctionArgInfo::PreloadedValue) const;
550b57cec5SDimitry Andric 
560b57cec5SDimitry Andric   SDValue LowerGlobalAddress(AMDGPUMachineFunction *MFI, SDValue Op,
570b57cec5SDimitry Andric                              SelectionDAG &DAG) const override;
580b57cec5SDimitry Andric   SDValue lowerImplicitZextParam(SelectionDAG &DAG, SDValue Op,
590b57cec5SDimitry Andric                                  MVT VT, unsigned Offset) const;
600b57cec5SDimitry Andric   SDValue lowerImage(SDValue Op, const AMDGPU::ImageDimIntrinsicInfo *Intr,
610b57cec5SDimitry Andric                      SelectionDAG &DAG) const;
620b57cec5SDimitry Andric   SDValue lowerSBuffer(EVT VT, SDLoc DL, SDValue Rsrc, SDValue Offset,
630b57cec5SDimitry Andric                        SDValue GLC, SDValue DLC, SelectionDAG &DAG) const;
640b57cec5SDimitry Andric 
650b57cec5SDimitry Andric   SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
660b57cec5SDimitry Andric   SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const;
670b57cec5SDimitry Andric   SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
680b57cec5SDimitry Andric 
690b57cec5SDimitry Andric   // The raw.tbuffer and struct.tbuffer intrinsics have two offset args: offset
700b57cec5SDimitry Andric   // (the offset that is included in bounds checking and swizzling, to be split
710b57cec5SDimitry Andric   // between the instruction's voffset and immoffset fields) and soffset (the
720b57cec5SDimitry Andric   // offset that is excluded from bounds checking and swizzling, to go in the
730b57cec5SDimitry Andric   // instruction's soffset field).  This function takes the first kind of
740b57cec5SDimitry Andric   // offset and figures out how to split it between voffset and immoffset.
750b57cec5SDimitry Andric   std::pair<SDValue, SDValue> splitBufferOffsets(SDValue Offset,
760b57cec5SDimitry Andric                                                  SelectionDAG &DAG) const;
770b57cec5SDimitry Andric 
780b57cec5SDimitry Andric   SDValue widenLoad(LoadSDNode *Ld, DAGCombinerInfo &DCI) const;
790b57cec5SDimitry Andric   SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
800b57cec5SDimitry Andric   SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
810b57cec5SDimitry Andric   SDValue lowerFastUnsafeFDIV(SDValue Op, SelectionDAG &DAG) const;
820b57cec5SDimitry Andric   SDValue lowerFDIV_FAST(SDValue Op, SelectionDAG &DAG) const;
830b57cec5SDimitry Andric   SDValue LowerFDIV16(SDValue Op, SelectionDAG &DAG) const;
840b57cec5SDimitry Andric   SDValue LowerFDIV32(SDValue Op, SelectionDAG &DAG) const;
850b57cec5SDimitry Andric   SDValue LowerFDIV64(SDValue Op, SelectionDAG &DAG) const;
860b57cec5SDimitry Andric   SDValue LowerFDIV(SDValue Op, SelectionDAG &DAG) const;
870b57cec5SDimitry Andric   SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG, bool Signed) const;
880b57cec5SDimitry Andric   SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
890b57cec5SDimitry Andric   SDValue LowerTrig(SDValue Op, SelectionDAG &DAG) const;
900b57cec5SDimitry Andric   SDValue LowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const;
910b57cec5SDimitry Andric   SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
920b57cec5SDimitry Andric   SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
930b57cec5SDimitry Andric   SDValue adjustLoadValueType(unsigned Opcode, MemSDNode *M,
940b57cec5SDimitry Andric                               SelectionDAG &DAG, ArrayRef<SDValue> Ops,
950b57cec5SDimitry Andric                               bool IsIntrinsic = false) const;
960b57cec5SDimitry Andric 
978bcb0991SDimitry Andric   SDValue lowerIntrinsicLoad(MemSDNode *M, bool IsFormat, SelectionDAG &DAG,
988bcb0991SDimitry Andric                              ArrayRef<SDValue> Ops) const;
998bcb0991SDimitry Andric 
1000b57cec5SDimitry Andric   // Call DAG.getMemIntrinsicNode for a load, but first widen a dwordx3 type to
1010b57cec5SDimitry Andric   // dwordx4 if on SI.
1020b57cec5SDimitry Andric   SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1030b57cec5SDimitry Andric                               ArrayRef<SDValue> Ops, EVT MemVT,
1040b57cec5SDimitry Andric                               MachineMemOperand *MMO, SelectionDAG &DAG) const;
1050b57cec5SDimitry Andric 
1060b57cec5SDimitry Andric   SDValue handleD16VData(SDValue VData, SelectionDAG &DAG) const;
1070b57cec5SDimitry Andric 
1080b57cec5SDimitry Andric   /// Converts \p Op, which must be of floating point type, to the
1090b57cec5SDimitry Andric   /// floating point type \p VT, by either extending or truncating it.
1100b57cec5SDimitry Andric   SDValue getFPExtOrFPTrunc(SelectionDAG &DAG,
1110b57cec5SDimitry Andric                             SDValue Op,
1120b57cec5SDimitry Andric                             const SDLoc &DL,
1130b57cec5SDimitry Andric                             EVT VT) const;
1140b57cec5SDimitry Andric 
1150b57cec5SDimitry Andric   SDValue convertArgType(
1160b57cec5SDimitry Andric     SelectionDAG &DAG, EVT VT, EVT MemVT, const SDLoc &SL, SDValue Val,
1170b57cec5SDimitry Andric     bool Signed, const ISD::InputArg *Arg = nullptr) const;
1180b57cec5SDimitry Andric 
1190b57cec5SDimitry Andric   /// Custom lowering for ISD::FP_ROUND for MVT::f16.
1200b57cec5SDimitry Andric   SDValue lowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
1210b57cec5SDimitry Andric   SDValue lowerFMINNUM_FMAXNUM(SDValue Op, SelectionDAG &DAG) const;
1220b57cec5SDimitry Andric 
1230b57cec5SDimitry Andric   SDValue getSegmentAperture(unsigned AS, const SDLoc &DL,
1240b57cec5SDimitry Andric                              SelectionDAG &DAG) const;
1250b57cec5SDimitry Andric 
1260b57cec5SDimitry Andric   SDValue lowerADDRSPACECAST(SDValue Op, SelectionDAG &DAG) const;
1270b57cec5SDimitry Andric   SDValue lowerINSERT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
1280b57cec5SDimitry Andric   SDValue lowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
1290b57cec5SDimitry Andric   SDValue lowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
1300b57cec5SDimitry Andric   SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;
1310b57cec5SDimitry Andric   SDValue lowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
1320b57cec5SDimitry Andric   SDValue lowerTRAP(SDValue Op, SelectionDAG &DAG) const;
1330b57cec5SDimitry Andric   SDValue lowerDEBUGTRAP(SDValue Op, SelectionDAG &DAG) const;
1340b57cec5SDimitry Andric 
1350b57cec5SDimitry Andric   SDNode *adjustWritemask(MachineSDNode *&N, SelectionDAG &DAG) const;
1360b57cec5SDimitry Andric 
1370b57cec5SDimitry Andric   SDValue performUCharToFloatCombine(SDNode *N,
1380b57cec5SDimitry Andric                                      DAGCombinerInfo &DCI) const;
1390b57cec5SDimitry Andric   SDValue performSHLPtrCombine(SDNode *N,
1400b57cec5SDimitry Andric                                unsigned AS,
1410b57cec5SDimitry Andric                                EVT MemVT,
1420b57cec5SDimitry Andric                                DAGCombinerInfo &DCI) const;
1430b57cec5SDimitry Andric 
1440b57cec5SDimitry Andric   SDValue performMemSDNodeCombine(MemSDNode *N, DAGCombinerInfo &DCI) const;
1450b57cec5SDimitry Andric 
1460b57cec5SDimitry Andric   SDValue splitBinaryBitConstantOp(DAGCombinerInfo &DCI, const SDLoc &SL,
1470b57cec5SDimitry Andric                                    unsigned Opc, SDValue LHS,
1480b57cec5SDimitry Andric                                    const ConstantSDNode *CRHS) const;
1490b57cec5SDimitry Andric 
1500b57cec5SDimitry Andric   SDValue performAndCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1510b57cec5SDimitry Andric   SDValue performOrCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1520b57cec5SDimitry Andric   SDValue performXorCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1530b57cec5SDimitry Andric   SDValue performZeroExtendCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1540b57cec5SDimitry Andric   SDValue performSignExtendInRegCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1550b57cec5SDimitry Andric   SDValue performClassCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1560b57cec5SDimitry Andric   SDValue getCanonicalConstantFP(SelectionDAG &DAG, const SDLoc &SL, EVT VT,
1570b57cec5SDimitry Andric                                  const APFloat &C) const;
1580b57cec5SDimitry Andric   SDValue performFCanonicalizeCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1590b57cec5SDimitry Andric 
1600b57cec5SDimitry Andric   SDValue performFPMed3ImmCombine(SelectionDAG &DAG, const SDLoc &SL,
1610b57cec5SDimitry Andric                                   SDValue Op0, SDValue Op1) const;
1620b57cec5SDimitry Andric   SDValue performIntMed3ImmCombine(SelectionDAG &DAG, const SDLoc &SL,
1630b57cec5SDimitry Andric                                    SDValue Op0, SDValue Op1, bool Signed) const;
1640b57cec5SDimitry Andric   SDValue performMinMaxCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1650b57cec5SDimitry Andric   SDValue performFMed3Combine(SDNode *N, DAGCombinerInfo &DCI) const;
1660b57cec5SDimitry Andric   SDValue performCvtPkRTZCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1670b57cec5SDimitry Andric   SDValue performExtractVectorEltCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1680b57cec5SDimitry Andric   SDValue performInsertVectorEltCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1690b57cec5SDimitry Andric 
1700b57cec5SDimitry Andric   SDValue reassociateScalarOps(SDNode *N, SelectionDAG &DAG) const;
1710b57cec5SDimitry Andric   unsigned getFusedOpcode(const SelectionDAG &DAG,
1720b57cec5SDimitry Andric                           const SDNode *N0, const SDNode *N1) const;
1730b57cec5SDimitry Andric   SDValue performAddCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1740b57cec5SDimitry Andric   SDValue performAddCarrySubCarryCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1750b57cec5SDimitry Andric   SDValue performSubCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1760b57cec5SDimitry Andric   SDValue performFAddCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1770b57cec5SDimitry Andric   SDValue performFSubCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1780b57cec5SDimitry Andric   SDValue performFMACombine(SDNode *N, DAGCombinerInfo &DCI) const;
1790b57cec5SDimitry Andric   SDValue performSetCCCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1800b57cec5SDimitry Andric   SDValue performCvtF32UByteNCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1810b57cec5SDimitry Andric   SDValue performClampCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1820b57cec5SDimitry Andric   SDValue performRcpCombine(SDNode *N, DAGCombinerInfo &DCI) const;
1830b57cec5SDimitry Andric 
1840b57cec5SDimitry Andric   bool isLegalFlatAddressingMode(const AddrMode &AM) const;
1850b57cec5SDimitry Andric   bool isLegalMUBUFAddressingMode(const AddrMode &AM) const;
1860b57cec5SDimitry Andric 
1870b57cec5SDimitry Andric   unsigned isCFIntrinsic(const SDNode *Intr) const;
1880b57cec5SDimitry Andric 
1898bcb0991SDimitry Andric public:
1900b57cec5SDimitry Andric   /// \returns True if fixup needs to be emitted for given global value \p GV,
1910b57cec5SDimitry Andric   /// false otherwise.
1920b57cec5SDimitry Andric   bool shouldEmitFixup(const GlobalValue *GV) const;
1930b57cec5SDimitry Andric 
1940b57cec5SDimitry Andric   /// \returns True if GOT relocation needs to be emitted for given global value
1950b57cec5SDimitry Andric   /// \p GV, false otherwise.
1960b57cec5SDimitry Andric   bool shouldEmitGOTReloc(const GlobalValue *GV) const;
1970b57cec5SDimitry Andric 
1980b57cec5SDimitry Andric   /// \returns True if PC-relative relocation needs to be emitted for given
1990b57cec5SDimitry Andric   /// global value \p GV, false otherwise.
2000b57cec5SDimitry Andric   bool shouldEmitPCReloc(const GlobalValue *GV) const;
2010b57cec5SDimitry Andric 
2028bcb0991SDimitry Andric private:
2030b57cec5SDimitry Andric   // Analyze a combined offset from an amdgcn_buffer_ intrinsic and store the
2040b57cec5SDimitry Andric   // three offsets (voffset, soffset and instoffset) into the SDValue[3] array
2050b57cec5SDimitry Andric   // pointed to by Offsets.
2068bcb0991SDimitry Andric   /// \returns 0 If there is a non-constant offset or if the offset is 0.
2078bcb0991SDimitry Andric   /// Otherwise returns the constant offset.
2088bcb0991SDimitry Andric   unsigned setBufferOffsets(SDValue CombinedOffset, SelectionDAG &DAG,
2090b57cec5SDimitry Andric                            SDValue *Offsets, unsigned Align = 4) const;
2100b57cec5SDimitry Andric 
2110b57cec5SDimitry Andric   // Handle 8 bit and 16 bit buffer loads
2120b57cec5SDimitry Andric   SDValue handleByteShortBufferLoads(SelectionDAG &DAG, EVT LoadVT, SDLoc DL,
2130b57cec5SDimitry Andric                                      ArrayRef<SDValue> Ops, MemSDNode *M) const;
2140b57cec5SDimitry Andric 
2150b57cec5SDimitry Andric   // Handle 8 bit and 16 bit buffer stores
2160b57cec5SDimitry Andric   SDValue handleByteShortBufferStores(SelectionDAG &DAG, EVT VDataType,
2170b57cec5SDimitry Andric                                       SDLoc DL, SDValue Ops[],
2180b57cec5SDimitry Andric                                       MemSDNode *M) const;
2190b57cec5SDimitry Andric 
2200b57cec5SDimitry Andric public:
2210b57cec5SDimitry Andric   SITargetLowering(const TargetMachine &tm, const GCNSubtarget &STI);
2220b57cec5SDimitry Andric 
2230b57cec5SDimitry Andric   const GCNSubtarget *getSubtarget() const;
2240b57cec5SDimitry Andric 
225*480093f4SDimitry Andric   bool isFPExtFoldable(const SelectionDAG &DAG, unsigned Opcode, EVT DestVT,
226*480093f4SDimitry Andric                        EVT SrcVT) const override;
2270b57cec5SDimitry Andric 
2280b57cec5SDimitry Andric   bool isShuffleMaskLegal(ArrayRef<int> /*Mask*/, EVT /*VT*/) const override;
2290b57cec5SDimitry Andric 
2300b57cec5SDimitry Andric   bool getTgtMemIntrinsic(IntrinsicInfo &, const CallInst &,
2310b57cec5SDimitry Andric                           MachineFunction &MF,
2320b57cec5SDimitry Andric                           unsigned IntrinsicID) const override;
2330b57cec5SDimitry Andric 
2340b57cec5SDimitry Andric   bool getAddrModeArguments(IntrinsicInst * /*I*/,
2350b57cec5SDimitry Andric                             SmallVectorImpl<Value*> &/*Ops*/,
2360b57cec5SDimitry Andric                             Type *&/*AccessTy*/) const override;
2370b57cec5SDimitry Andric 
2380b57cec5SDimitry Andric   bool isLegalGlobalAddressingMode(const AddrMode &AM) const;
2390b57cec5SDimitry Andric   bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
2400b57cec5SDimitry Andric                              unsigned AS,
2410b57cec5SDimitry Andric                              Instruction *I = nullptr) const override;
2420b57cec5SDimitry Andric 
2430b57cec5SDimitry Andric   bool canMergeStoresTo(unsigned AS, EVT MemVT,
2440b57cec5SDimitry Andric                         const SelectionDAG &DAG) const override;
2450b57cec5SDimitry Andric 
2468bcb0991SDimitry Andric   bool allowsMisalignedMemoryAccessesImpl(
2478bcb0991SDimitry Andric       unsigned Size, unsigned AS, unsigned Align,
2488bcb0991SDimitry Andric       MachineMemOperand::Flags Flags = MachineMemOperand::MONone,
2498bcb0991SDimitry Andric       bool *IsFast = nullptr) const;
2508bcb0991SDimitry Andric 
2510b57cec5SDimitry Andric   bool allowsMisalignedMemoryAccesses(
2520b57cec5SDimitry Andric       EVT VT, unsigned AS, unsigned Align,
2530b57cec5SDimitry Andric       MachineMemOperand::Flags Flags = MachineMemOperand::MONone,
2540b57cec5SDimitry Andric       bool *IsFast = nullptr) const override;
2550b57cec5SDimitry Andric 
2560b57cec5SDimitry Andric   EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign,
2570b57cec5SDimitry Andric                           unsigned SrcAlign, bool IsMemset,
2580b57cec5SDimitry Andric                           bool ZeroMemset,
2590b57cec5SDimitry Andric                           bool MemcpyStrSrc,
2600b57cec5SDimitry Andric                           const AttributeList &FuncAttributes) const override;
2610b57cec5SDimitry Andric 
2620b57cec5SDimitry Andric   bool isMemOpUniform(const SDNode *N) const;
2630b57cec5SDimitry Andric   bool isMemOpHasNoClobberedMemOperand(const SDNode *N) const;
264*480093f4SDimitry Andric 
265*480093f4SDimitry Andric   static bool isFlatGlobalAddrSpace(unsigned AS) {
266*480093f4SDimitry Andric     return AS == AMDGPUAS::GLOBAL_ADDRESS ||
267*480093f4SDimitry Andric            AS == AMDGPUAS::FLAT_ADDRESS ||
268*480093f4SDimitry Andric            AS == AMDGPUAS::CONSTANT_ADDRESS ||
269*480093f4SDimitry Andric            AS > AMDGPUAS::MAX_AMDGPU_ADDRESS;
270*480093f4SDimitry Andric   }
271*480093f4SDimitry Andric 
2720b57cec5SDimitry Andric   bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override;
2730b57cec5SDimitry Andric   bool isFreeAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override;
2740b57cec5SDimitry Andric 
2750b57cec5SDimitry Andric   TargetLoweringBase::LegalizeTypeAction
2760b57cec5SDimitry Andric   getPreferredVectorAction(MVT VT) const override;
2770b57cec5SDimitry Andric 
2780b57cec5SDimitry Andric   bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
2790b57cec5SDimitry Andric                                         Type *Ty) const override;
2800b57cec5SDimitry Andric 
2810b57cec5SDimitry Andric   bool isTypeDesirableForOp(unsigned Op, EVT VT) const override;
2820b57cec5SDimitry Andric 
2830b57cec5SDimitry Andric   bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
2840b57cec5SDimitry Andric 
2850b57cec5SDimitry Andric   bool supportSplitCSR(MachineFunction *MF) const override;
2860b57cec5SDimitry Andric   void initializeSplitCSR(MachineBasicBlock *Entry) const override;
2870b57cec5SDimitry Andric   void insertCopiesSplitCSR(
2880b57cec5SDimitry Andric     MachineBasicBlock *Entry,
2890b57cec5SDimitry Andric     const SmallVectorImpl<MachineBasicBlock *> &Exits) const override;
2900b57cec5SDimitry Andric 
2910b57cec5SDimitry Andric   SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
2920b57cec5SDimitry Andric                                bool isVarArg,
2930b57cec5SDimitry Andric                                const SmallVectorImpl<ISD::InputArg> &Ins,
2940b57cec5SDimitry Andric                                const SDLoc &DL, SelectionDAG &DAG,
2950b57cec5SDimitry Andric                                SmallVectorImpl<SDValue> &InVals) const override;
2960b57cec5SDimitry Andric 
2970b57cec5SDimitry Andric   bool CanLowerReturn(CallingConv::ID CallConv,
2980b57cec5SDimitry Andric                       MachineFunction &MF, bool isVarArg,
2990b57cec5SDimitry Andric                       const SmallVectorImpl<ISD::OutputArg> &Outs,
3000b57cec5SDimitry Andric                       LLVMContext &Context) const override;
3010b57cec5SDimitry Andric 
3020b57cec5SDimitry Andric   SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
3030b57cec5SDimitry Andric                       const SmallVectorImpl<ISD::OutputArg> &Outs,
3040b57cec5SDimitry Andric                       const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
3050b57cec5SDimitry Andric                       SelectionDAG &DAG) const override;
3060b57cec5SDimitry Andric 
3070b57cec5SDimitry Andric   void passSpecialInputs(
3080b57cec5SDimitry Andric     CallLoweringInfo &CLI,
3090b57cec5SDimitry Andric     CCState &CCInfo,
3100b57cec5SDimitry Andric     const SIMachineFunctionInfo &Info,
3110b57cec5SDimitry Andric     SmallVectorImpl<std::pair<unsigned, SDValue>> &RegsToPass,
3120b57cec5SDimitry Andric     SmallVectorImpl<SDValue> &MemOpChains,
3130b57cec5SDimitry Andric     SDValue Chain) const;
3140b57cec5SDimitry Andric 
3150b57cec5SDimitry Andric   SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
3160b57cec5SDimitry Andric                           CallingConv::ID CallConv, bool isVarArg,
3170b57cec5SDimitry Andric                           const SmallVectorImpl<ISD::InputArg> &Ins,
3180b57cec5SDimitry Andric                           const SDLoc &DL, SelectionDAG &DAG,
3190b57cec5SDimitry Andric                           SmallVectorImpl<SDValue> &InVals, bool isThisReturn,
3200b57cec5SDimitry Andric                           SDValue ThisVal) const;
3210b57cec5SDimitry Andric 
3220b57cec5SDimitry Andric   bool mayBeEmittedAsTailCall(const CallInst *) const override;
3230b57cec5SDimitry Andric 
3240b57cec5SDimitry Andric   bool isEligibleForTailCallOptimization(
3250b57cec5SDimitry Andric     SDValue Callee, CallingConv::ID CalleeCC, bool isVarArg,
3260b57cec5SDimitry Andric     const SmallVectorImpl<ISD::OutputArg> &Outs,
3270b57cec5SDimitry Andric     const SmallVectorImpl<SDValue> &OutVals,
3280b57cec5SDimitry Andric     const SmallVectorImpl<ISD::InputArg> &Ins, SelectionDAG &DAG) const;
3290b57cec5SDimitry Andric 
3300b57cec5SDimitry Andric   SDValue LowerCall(CallLoweringInfo &CLI,
3310b57cec5SDimitry Andric                     SmallVectorImpl<SDValue> &InVals) const override;
3320b57cec5SDimitry Andric 
333*480093f4SDimitry Andric   Register getRegisterByName(const char* RegName, LLT VT,
3348bcb0991SDimitry Andric                              const MachineFunction &MF) const override;
3350b57cec5SDimitry Andric 
3360b57cec5SDimitry Andric   MachineBasicBlock *splitKillBlock(MachineInstr &MI,
3370b57cec5SDimitry Andric                                     MachineBasicBlock *BB) const;
3380b57cec5SDimitry Andric 
3398bcb0991SDimitry Andric   void bundleInstWithWaitcnt(MachineInstr &MI) const;
3400b57cec5SDimitry Andric   MachineBasicBlock *emitGWSMemViolTestLoop(MachineInstr &MI,
3410b57cec5SDimitry Andric                                             MachineBasicBlock *BB) const;
3420b57cec5SDimitry Andric 
3430b57cec5SDimitry Andric   MachineBasicBlock *
3440b57cec5SDimitry Andric   EmitInstrWithCustomInserter(MachineInstr &MI,
3450b57cec5SDimitry Andric                               MachineBasicBlock *BB) const override;
3460b57cec5SDimitry Andric 
3470b57cec5SDimitry Andric   bool hasBitPreservingFPLogic(EVT VT) const override;
3480b57cec5SDimitry Andric   bool enableAggressiveFMAFusion(EVT VT) const override;
3490b57cec5SDimitry Andric   EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
3500b57cec5SDimitry Andric                          EVT VT) const override;
3510b57cec5SDimitry Andric   MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override;
352*480093f4SDimitry Andric   bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
353*480093f4SDimitry Andric                                   EVT VT) const override;
354*480093f4SDimitry Andric   bool isFMADLegalForFAddFSub(const SelectionDAG &DAG,
355*480093f4SDimitry Andric                               const SDNode *N) const override;
356*480093f4SDimitry Andric 
3570b57cec5SDimitry Andric   SDValue splitUnaryVectorOp(SDValue Op, SelectionDAG &DAG) const;
3580b57cec5SDimitry Andric   SDValue splitBinaryVectorOp(SDValue Op, SelectionDAG &DAG) const;
3598bcb0991SDimitry Andric   SDValue splitTernaryVectorOp(SDValue Op, SelectionDAG &DAG) const;
3600b57cec5SDimitry Andric   SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
3610b57cec5SDimitry Andric 
3620b57cec5SDimitry Andric   void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
3630b57cec5SDimitry Andric                           SelectionDAG &DAG) const override;
3640b57cec5SDimitry Andric 
3650b57cec5SDimitry Andric   SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
3660b57cec5SDimitry Andric   SDNode *PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const override;
3670b57cec5SDimitry Andric   void AdjustInstrPostInstrSelection(MachineInstr &MI,
3680b57cec5SDimitry Andric                                      SDNode *Node) const override;
3690b57cec5SDimitry Andric 
3700b57cec5SDimitry Andric   SDNode *legalizeTargetIndependentNode(SDNode *Node, SelectionDAG &DAG) const;
3710b57cec5SDimitry Andric 
3720b57cec5SDimitry Andric   MachineSDNode *wrapAddr64Rsrc(SelectionDAG &DAG, const SDLoc &DL,
3730b57cec5SDimitry Andric                                 SDValue Ptr) const;
3740b57cec5SDimitry Andric   MachineSDNode *buildRSRC(SelectionDAG &DAG, const SDLoc &DL, SDValue Ptr,
3750b57cec5SDimitry Andric                            uint32_t RsrcDword1, uint64_t RsrcDword2And3) const;
3760b57cec5SDimitry Andric   std::pair<unsigned, const TargetRegisterClass *>
3770b57cec5SDimitry Andric   getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
3780b57cec5SDimitry Andric                                StringRef Constraint, MVT VT) const override;
3790b57cec5SDimitry Andric   ConstraintType getConstraintType(StringRef Constraint) const override;
3800b57cec5SDimitry Andric   SDValue copyToM0(SelectionDAG &DAG, SDValue Chain, const SDLoc &DL,
3810b57cec5SDimitry Andric                    SDValue V) const;
3820b57cec5SDimitry Andric 
3830b57cec5SDimitry Andric   void finalizeLowering(MachineFunction &MF) const override;
3840b57cec5SDimitry Andric 
3850b57cec5SDimitry Andric   void computeKnownBitsForFrameIndex(const SDValue Op,
3860b57cec5SDimitry Andric                                      KnownBits &Known,
3870b57cec5SDimitry Andric                                      const APInt &DemandedElts,
3880b57cec5SDimitry Andric                                      const SelectionDAG &DAG,
3890b57cec5SDimitry Andric                                      unsigned Depth = 0) const override;
3900b57cec5SDimitry Andric 
3910b57cec5SDimitry Andric   bool isSDNodeSourceOfDivergence(const SDNode *N,
3920b57cec5SDimitry Andric     FunctionLoweringInfo *FLI, LegacyDivergenceAnalysis *DA) const override;
3930b57cec5SDimitry Andric 
3940b57cec5SDimitry Andric   bool isCanonicalized(SelectionDAG &DAG, SDValue Op,
3950b57cec5SDimitry Andric                        unsigned MaxDepth = 5) const;
396*480093f4SDimitry Andric   bool denormalsEnabledForType(const SelectionDAG &DAG, EVT VT) const;
3970b57cec5SDimitry Andric 
3980b57cec5SDimitry Andric   bool isKnownNeverNaNForTargetNode(SDValue Op,
3990b57cec5SDimitry Andric                                     const SelectionDAG &DAG,
4000b57cec5SDimitry Andric                                     bool SNaN = false,
4010b57cec5SDimitry Andric                                     unsigned Depth = 0) const override;
4020b57cec5SDimitry Andric   AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *) const override;
4030b57cec5SDimitry Andric 
4048bcb0991SDimitry Andric   virtual const TargetRegisterClass *
4058bcb0991SDimitry Andric   getRegClassFor(MVT VT, bool isDivergent) const override;
4068bcb0991SDimitry Andric   virtual bool requiresUniformRegister(MachineFunction &MF,
4078bcb0991SDimitry Andric                                        const Value *V) const override;
4088bcb0991SDimitry Andric   Align getPrefLoopAlignment(MachineLoop *ML) const override;
4098bcb0991SDimitry Andric 
4108bcb0991SDimitry Andric   void allocateHSAUserSGPRs(CCState &CCInfo,
4118bcb0991SDimitry Andric                             MachineFunction &MF,
4128bcb0991SDimitry Andric                             const SIRegisterInfo &TRI,
4138bcb0991SDimitry Andric                             SIMachineFunctionInfo &Info) const;
4148bcb0991SDimitry Andric 
4158bcb0991SDimitry Andric   void allocateSystemSGPRs(CCState &CCInfo,
4168bcb0991SDimitry Andric                            MachineFunction &MF,
4178bcb0991SDimitry Andric                            SIMachineFunctionInfo &Info,
4188bcb0991SDimitry Andric                            CallingConv::ID CallConv,
4198bcb0991SDimitry Andric                            bool IsShader) const;
4208bcb0991SDimitry Andric 
4218bcb0991SDimitry Andric   void allocateSpecialEntryInputVGPRs(CCState &CCInfo,
4228bcb0991SDimitry Andric                                       MachineFunction &MF,
4238bcb0991SDimitry Andric                                       const SIRegisterInfo &TRI,
4248bcb0991SDimitry Andric                                       SIMachineFunctionInfo &Info) const;
4258bcb0991SDimitry Andric   void allocateSpecialInputSGPRs(
4268bcb0991SDimitry Andric     CCState &CCInfo,
4278bcb0991SDimitry Andric     MachineFunction &MF,
4288bcb0991SDimitry Andric     const SIRegisterInfo &TRI,
4298bcb0991SDimitry Andric     SIMachineFunctionInfo &Info) const;
4308bcb0991SDimitry Andric 
4318bcb0991SDimitry Andric   void allocateSpecialInputVGPRs(CCState &CCInfo,
4328bcb0991SDimitry Andric                                  MachineFunction &MF,
4338bcb0991SDimitry Andric                                  const SIRegisterInfo &TRI,
4348bcb0991SDimitry Andric                                  SIMachineFunctionInfo &Info) const;
4350b57cec5SDimitry Andric };
4360b57cec5SDimitry Andric 
4370b57cec5SDimitry Andric } // End namespace llvm
4380b57cec5SDimitry Andric 
4390b57cec5SDimitry Andric #endif
440