xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric //===- AMDGPUInstructionSelector --------------------------------*- 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 /// \file
90b57cec5SDimitry Andric /// This file declares the targeting of the InstructionSelector class for
100b57cec5SDimitry Andric /// AMDGPU.
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUINSTRUCTIONSELECTOR_H
140b57cec5SDimitry Andric #define LLVM_LIB_TARGET_AMDGPU_AMDGPUINSTRUCTIONSELECTOR_H
150b57cec5SDimitry Andric 
1606c3fb27SDimitry Andric #include "SIDefines.h"
170b57cec5SDimitry Andric #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
180b57cec5SDimitry Andric #include "llvm/IR/InstrTypes.h"
190b57cec5SDimitry Andric 
200b57cec5SDimitry Andric namespace {
210b57cec5SDimitry Andric #define GET_GLOBALISEL_PREDICATE_BITSET
220b57cec5SDimitry Andric #define AMDGPUSubtarget GCNSubtarget
230b57cec5SDimitry Andric #include "AMDGPUGenGlobalISel.inc"
240b57cec5SDimitry Andric #undef GET_GLOBALISEL_PREDICATE_BITSET
250b57cec5SDimitry Andric #undef AMDGPUSubtarget
260b57cec5SDimitry Andric }
270b57cec5SDimitry Andric 
280b57cec5SDimitry Andric namespace llvm {
290b57cec5SDimitry Andric 
305ffd83dbSDimitry Andric namespace AMDGPU {
315ffd83dbSDimitry Andric struct ImageDimIntrinsicInfo;
325ffd83dbSDimitry Andric }
335ffd83dbSDimitry Andric 
340b57cec5SDimitry Andric class AMDGPURegisterBankInfo;
35e8d8bef9SDimitry Andric class AMDGPUTargetMachine;
36fe6060f1SDimitry Andric class BlockFrequencyInfo;
37fe6060f1SDimitry Andric class ProfileSummaryInfo;
380b57cec5SDimitry Andric class GCNSubtarget;
390b57cec5SDimitry Andric class MachineInstr;
408bcb0991SDimitry Andric class MachineIRBuilder;
410b57cec5SDimitry Andric class MachineOperand;
420b57cec5SDimitry Andric class MachineRegisterInfo;
43480093f4SDimitry Andric class RegisterBank;
440b57cec5SDimitry Andric class SIInstrInfo;
450b57cec5SDimitry Andric class SIRegisterInfo;
46fe6060f1SDimitry Andric class TargetRegisterClass;
470b57cec5SDimitry Andric 
48e8d8bef9SDimitry Andric class AMDGPUInstructionSelector final : public InstructionSelector {
498bcb0991SDimitry Andric private:
508bcb0991SDimitry Andric   MachineRegisterInfo *MRI;
51e8d8bef9SDimitry Andric   const GCNSubtarget *Subtarget;
528bcb0991SDimitry Andric 
530b57cec5SDimitry Andric public:
540b57cec5SDimitry Andric   AMDGPUInstructionSelector(const GCNSubtarget &STI,
550b57cec5SDimitry Andric                             const AMDGPURegisterBankInfo &RBI,
560b57cec5SDimitry Andric                             const AMDGPUTargetMachine &TM);
570b57cec5SDimitry Andric 
588bcb0991SDimitry Andric   bool select(MachineInstr &I) override;
590b57cec5SDimitry Andric   static const char *getName();
600b57cec5SDimitry Andric 
61fe6060f1SDimitry Andric   void setupMF(MachineFunction &MF, GISelKnownBits *KB,
6206c3fb27SDimitry Andric                CodeGenCoverage *CoverageInfo, ProfileSummaryInfo *PSI,
63fe6060f1SDimitry Andric                BlockFrequencyInfo *BFI) override;
648bcb0991SDimitry Andric 
650b57cec5SDimitry Andric private:
660b57cec5SDimitry Andric   struct GEPInfo {
670b57cec5SDimitry Andric     SmallVector<unsigned, 2> SgprParts;
680b57cec5SDimitry Andric     SmallVector<unsigned, 2> VgprParts;
69fcaf7f86SDimitry Andric     int64_t Imm = 0;
700b57cec5SDimitry Andric   };
710b57cec5SDimitry Andric 
72e8d8bef9SDimitry Andric   bool isSGPR(Register Reg) const;
73e8d8bef9SDimitry Andric 
740b57cec5SDimitry Andric   bool isInstrUniform(const MachineInstr &MI) const;
750b57cec5SDimitry Andric   bool isVCC(Register Reg, const MachineRegisterInfo &MRI) const;
760b57cec5SDimitry Andric 
77480093f4SDimitry Andric   const RegisterBank *getArtifactRegBank(
78480093f4SDimitry Andric     Register Reg, const MachineRegisterInfo &MRI,
79480093f4SDimitry Andric     const TargetRegisterInfo &TRI) const;
80480093f4SDimitry Andric 
810b57cec5SDimitry Andric   /// tblgen-erated 'select' implementation.
820b57cec5SDimitry Andric   bool selectImpl(MachineInstr &I, CodeGenCoverage &CoverageInfo) const;
830b57cec5SDimitry Andric 
840b57cec5SDimitry Andric   MachineOperand getSubOperand64(MachineOperand &MO,
850b57cec5SDimitry Andric                                  const TargetRegisterClass &SubRC,
860b57cec5SDimitry Andric                                  unsigned SubIdx) const;
875ffd83dbSDimitry Andric 
885ffd83dbSDimitry Andric   bool constrainCopyLikeIntrin(MachineInstr &MI, unsigned NewOpc) const;
890b57cec5SDimitry Andric   bool selectCOPY(MachineInstr &I) const;
900b57cec5SDimitry Andric   bool selectPHI(MachineInstr &I) const;
910b57cec5SDimitry Andric   bool selectG_TRUNC(MachineInstr &I) const;
920b57cec5SDimitry Andric   bool selectG_SZA_EXT(MachineInstr &I) const;
935f757f3fSDimitry Andric   bool selectG_FPEXT(MachineInstr &I) const;
940b57cec5SDimitry Andric   bool selectG_CONSTANT(MachineInstr &I) const;
955ffd83dbSDimitry Andric   bool selectG_FNEG(MachineInstr &I) const;
965ffd83dbSDimitry Andric   bool selectG_FABS(MachineInstr &I) const;
970b57cec5SDimitry Andric   bool selectG_AND_OR_XOR(MachineInstr &I) const;
980b57cec5SDimitry Andric   bool selectG_ADD_SUB(MachineInstr &I) const;
99480093f4SDimitry Andric   bool selectG_UADDO_USUBO_UADDE_USUBE(MachineInstr &I) const;
10081ad6265SDimitry Andric   bool selectG_AMDGPU_MAD_64_32(MachineInstr &I) const;
1010b57cec5SDimitry Andric   bool selectG_EXTRACT(MachineInstr &I) const;
102bdd1243dSDimitry Andric   bool selectG_FMA_FMAD(MachineInstr &I) const;
1030b57cec5SDimitry Andric   bool selectG_MERGE_VALUES(MachineInstr &I) const;
1040b57cec5SDimitry Andric   bool selectG_UNMERGE_VALUES(MachineInstr &I) const;
105bdd1243dSDimitry Andric   bool selectG_BUILD_VECTOR(MachineInstr &I) const;
1060b57cec5SDimitry Andric   bool selectG_IMPLICIT_DEF(MachineInstr &I) const;
1070b57cec5SDimitry Andric   bool selectG_INSERT(MachineInstr &I) const;
108fe6060f1SDimitry Andric   bool selectG_SBFX_UBFX(MachineInstr &I) const;
1095ffd83dbSDimitry Andric 
1105ffd83dbSDimitry Andric   bool selectInterpP1F16(MachineInstr &MI) const;
111e8d8bef9SDimitry Andric   bool selectWritelane(MachineInstr &MI) const;
1125ffd83dbSDimitry Andric   bool selectDivScale(MachineInstr &MI) const;
113bdd1243dSDimitry Andric   bool selectIntrinsicCmp(MachineInstr &MI) const;
1145ffd83dbSDimitry Andric   bool selectBallot(MachineInstr &I) const;
115e8d8bef9SDimitry Andric   bool selectRelocConstant(MachineInstr &I) const;
116e8d8bef9SDimitry Andric   bool selectGroupStaticSize(MachineInstr &I) const;
117e8d8bef9SDimitry Andric   bool selectReturnAddress(MachineInstr &I) const;
1188bcb0991SDimitry Andric   bool selectG_INTRINSIC(MachineInstr &I) const;
1198bcb0991SDimitry Andric 
1205ffd83dbSDimitry Andric   bool selectEndCfIntrinsic(MachineInstr &MI) const;
121480093f4SDimitry Andric   bool selectDSOrderedIntrinsic(MachineInstr &MI, Intrinsic::ID IID) const;
1225ffd83dbSDimitry Andric   bool selectDSGWSIntrinsic(MachineInstr &MI, Intrinsic::ID IID) const;
1235ffd83dbSDimitry Andric   bool selectDSAppendConsume(MachineInstr &MI, bool IsAppend) const;
124e8d8bef9SDimitry Andric   bool selectSBarrier(MachineInstr &MI) const;
125bdd1243dSDimitry Andric   bool selectDSBvhStackIntrinsic(MachineInstr &MI) const;
1268bcb0991SDimitry Andric 
1275ffd83dbSDimitry Andric   bool selectImageIntrinsic(MachineInstr &MI,
1285ffd83dbSDimitry Andric                             const AMDGPU::ImageDimIntrinsicInfo *Intr) const;
1298bcb0991SDimitry Andric   bool selectG_INTRINSIC_W_SIDE_EFFECTS(MachineInstr &I) const;
1300b57cec5SDimitry Andric   int getS_CMPOpcode(CmpInst::Predicate P, unsigned Size) const;
1315f757f3fSDimitry Andric   bool selectG_ICMP_or_FCMP(MachineInstr &I) const;
1320b57cec5SDimitry Andric   bool hasVgprParts(ArrayRef<GEPInfo> AddrInfo) const;
1330b57cec5SDimitry Andric   void getAddrModeInfo(const MachineInstr &Load, const MachineRegisterInfo &MRI,
1340b57cec5SDimitry Andric                        SmallVectorImpl<GEPInfo> &AddrInfo) const;
1358bcb0991SDimitry Andric 
1368bcb0991SDimitry Andric   void initM0(MachineInstr &I) const;
137e8d8bef9SDimitry Andric   bool selectG_LOAD_STORE_ATOMICRMW(MachineInstr &I) const;
1388bcb0991SDimitry Andric   bool selectG_SELECT(MachineInstr &I) const;
1390b57cec5SDimitry Andric   bool selectG_BRCOND(MachineInstr &I) const;
140e8d8bef9SDimitry Andric   bool selectG_GLOBAL_VALUE(MachineInstr &I) const;
1415ffd83dbSDimitry Andric   bool selectG_PTRMASK(MachineInstr &I) const;
142480093f4SDimitry Andric   bool selectG_EXTRACT_VECTOR_ELT(MachineInstr &I) const;
1435ffd83dbSDimitry Andric   bool selectG_INSERT_VECTOR_ELT(MachineInstr &I) const;
14481ad6265SDimitry Andric   bool selectBufferLoadLds(MachineInstr &MI) const;
14581ad6265SDimitry Andric   bool selectGlobalLoadLds(MachineInstr &MI) const;
146e8d8bef9SDimitry Andric   bool selectBVHIntrinsic(MachineInstr &I) const;
14781ad6265SDimitry Andric   bool selectSMFMACIntrin(MachineInstr &I) const;
14804eeddc0SDimitry Andric   bool selectWaveAddress(MachineInstr &I) const;
1495f757f3fSDimitry Andric   bool selectStackRestore(MachineInstr &MI) const;
1505f757f3fSDimitry Andric   bool selectNamedBarrierInst(MachineInstr &I, Intrinsic::ID IID) const;
1515f757f3fSDimitry Andric   bool selectSBarrierSignalIsfirst(MachineInstr &I, Intrinsic::ID IID) const;
1525f757f3fSDimitry Andric   bool selectSBarrierLeave(MachineInstr &I) const;
1530b57cec5SDimitry Andric 
15406c3fb27SDimitry Andric   std::pair<Register, unsigned> selectVOP3ModsImpl(MachineOperand &Root,
15506c3fb27SDimitry Andric                                                    bool IsCanonicalizing = true,
15606c3fb27SDimitry Andric                                                    bool AllowAbs = true,
157bdd1243dSDimitry Andric                                                    bool OpSel = false) const;
158bdd1243dSDimitry Andric 
159bdd1243dSDimitry Andric   Register copyToVGPRIfSrcFolded(Register Src, unsigned Mods,
160bdd1243dSDimitry Andric                                  MachineOperand Root, MachineInstr *InsertPt,
161bdd1243dSDimitry Andric                                  bool ForceVGPR = false) const;
1620b57cec5SDimitry Andric 
1630b57cec5SDimitry Andric   InstructionSelector::ComplexRendererFns
1640b57cec5SDimitry Andric   selectVCSRC(MachineOperand &Root) const;
1650b57cec5SDimitry Andric 
1660b57cec5SDimitry Andric   InstructionSelector::ComplexRendererFns
1670b57cec5SDimitry Andric   selectVSRC0(MachineOperand &Root) const;
1680b57cec5SDimitry Andric 
1690b57cec5SDimitry Andric   InstructionSelector::ComplexRendererFns
1700b57cec5SDimitry Andric   selectVOP3Mods0(MachineOperand &Root) const;
1710b57cec5SDimitry Andric   InstructionSelector::ComplexRendererFns
172e8d8bef9SDimitry Andric   selectVOP3BMods0(MachineOperand &Root) const;
173e8d8bef9SDimitry Andric   InstructionSelector::ComplexRendererFns
1740b57cec5SDimitry Andric   selectVOP3OMods(MachineOperand &Root) const;
1750b57cec5SDimitry Andric   InstructionSelector::ComplexRendererFns
1760b57cec5SDimitry Andric   selectVOP3Mods(MachineOperand &Root) const;
177e8d8bef9SDimitry Andric   InstructionSelector::ComplexRendererFns
17806c3fb27SDimitry Andric   selectVOP3ModsNonCanonicalizing(MachineOperand &Root) const;
17906c3fb27SDimitry Andric   InstructionSelector::ComplexRendererFns
180e8d8bef9SDimitry Andric   selectVOP3BMods(MachineOperand &Root) const;
1815ffd83dbSDimitry Andric 
1825ffd83dbSDimitry Andric   ComplexRendererFns selectVOP3NoMods(MachineOperand &Root) const;
1835ffd83dbSDimitry Andric 
1845ffd83dbSDimitry Andric   std::pair<Register, unsigned>
18581ad6265SDimitry Andric   selectVOP3PModsImpl(Register Src, const MachineRegisterInfo &MRI,
18681ad6265SDimitry Andric                       bool IsDOT = false) const;
1875ffd83dbSDimitry Andric 
1880b57cec5SDimitry Andric   InstructionSelector::ComplexRendererFns
1895ffd83dbSDimitry Andric   selectVOP3PMods(MachineOperand &Root) const;
1905ffd83dbSDimitry Andric 
1918bcb0991SDimitry Andric   InstructionSelector::ComplexRendererFns
19281ad6265SDimitry Andric   selectVOP3PModsDOT(MachineOperand &Root) const;
19381ad6265SDimitry Andric 
19481ad6265SDimitry Andric   InstructionSelector::ComplexRendererFns
1957a6dacacSDimitry Andric   selectVOP3PModsNeg(MachineOperand &Root) const;
19681ad6265SDimitry Andric 
19781ad6265SDimitry Andric   InstructionSelector::ComplexRendererFns
19881ad6265SDimitry Andric   selectWMMAOpSelVOP3PMods(MachineOperand &Root) const;
19981ad6265SDimitry Andric 
20081ad6265SDimitry Andric   InstructionSelector::ComplexRendererFns
201b3edf446SDimitry Andric   selectWMMAModsF32NegAbs(MachineOperand &Root) const;
202b3edf446SDimitry Andric   InstructionSelector::ComplexRendererFns
203b3edf446SDimitry Andric   selectWMMAModsF16Neg(MachineOperand &Root) const;
204b3edf446SDimitry Andric   InstructionSelector::ComplexRendererFns
205b3edf446SDimitry Andric   selectWMMAModsF16NegAbs(MachineOperand &Root) const;
206b3edf446SDimitry Andric   InstructionSelector::ComplexRendererFns
207b3edf446SDimitry Andric   selectWMMAVISrc(MachineOperand &Root) const;
208b3edf446SDimitry Andric   InstructionSelector::ComplexRendererFns
209b3edf446SDimitry Andric   selectSWMMACIndex8(MachineOperand &Root) const;
210b3edf446SDimitry Andric   InstructionSelector::ComplexRendererFns
211b3edf446SDimitry Andric   selectSWMMACIndex16(MachineOperand &Root) const;
212b3edf446SDimitry Andric 
213b3edf446SDimitry Andric   InstructionSelector::ComplexRendererFns
2148bcb0991SDimitry Andric   selectVOP3OpSelMods(MachineOperand &Root) const;
2158bcb0991SDimitry Andric 
2168bcb0991SDimitry Andric   InstructionSelector::ComplexRendererFns
21781ad6265SDimitry Andric   selectVINTERPMods(MachineOperand &Root) const;
21881ad6265SDimitry Andric   InstructionSelector::ComplexRendererFns
21981ad6265SDimitry Andric   selectVINTERPModsHi(MachineOperand &Root) const;
22081ad6265SDimitry Andric 
221fcaf7f86SDimitry Andric   bool selectSmrdOffset(MachineOperand &Root, Register &Base, Register *SOffset,
222fcaf7f86SDimitry Andric                         int64_t *Offset) const;
22381ad6265SDimitry Andric   InstructionSelector::ComplexRendererFns
2240b57cec5SDimitry Andric   selectSmrdImm(MachineOperand &Root) const;
2250b57cec5SDimitry Andric   InstructionSelector::ComplexRendererFns
2260b57cec5SDimitry Andric   selectSmrdImm32(MachineOperand &Root) const;
2270b57cec5SDimitry Andric   InstructionSelector::ComplexRendererFns
2280b57cec5SDimitry Andric   selectSmrdSgpr(MachineOperand &Root) const;
229fcaf7f86SDimitry Andric   InstructionSelector::ComplexRendererFns
230fcaf7f86SDimitry Andric   selectSmrdSgprImm(MachineOperand &Root) const;
2310b57cec5SDimitry Andric 
232fe6060f1SDimitry Andric   std::pair<Register, int> selectFlatOffsetImpl(MachineOperand &Root,
233fe6060f1SDimitry Andric                                                 uint64_t FlatVariant) const;
2340b57cec5SDimitry Andric 
2350b57cec5SDimitry Andric   InstructionSelector::ComplexRendererFns
236e8d8bef9SDimitry Andric   selectFlatOffset(MachineOperand &Root) const;
237e8d8bef9SDimitry Andric   InstructionSelector::ComplexRendererFns
238fe6060f1SDimitry Andric   selectGlobalOffset(MachineOperand &Root) const;
239fe6060f1SDimitry Andric   InstructionSelector::ComplexRendererFns
240fe6060f1SDimitry Andric   selectScratchOffset(MachineOperand &Root) const;
2410b57cec5SDimitry Andric 
2420b57cec5SDimitry Andric   InstructionSelector::ComplexRendererFns
243e8d8bef9SDimitry Andric   selectGlobalSAddr(MachineOperand &Root) const;
244e8d8bef9SDimitry Andric 
245e8d8bef9SDimitry Andric   InstructionSelector::ComplexRendererFns
246e8d8bef9SDimitry Andric   selectScratchSAddr(MachineOperand &Root) const;
24781ad6265SDimitry Andric   bool checkFlatScratchSVSSwizzleBug(Register VAddr, Register SAddr,
24881ad6265SDimitry Andric                                      uint64_t ImmOffset) const;
24981ad6265SDimitry Andric   InstructionSelector::ComplexRendererFns
25081ad6265SDimitry Andric   selectScratchSVAddr(MachineOperand &Root) const;
251e8d8bef9SDimitry Andric 
252e8d8bef9SDimitry Andric   InstructionSelector::ComplexRendererFns
2530b57cec5SDimitry Andric   selectMUBUFScratchOffen(MachineOperand &Root) const;
2540b57cec5SDimitry Andric   InstructionSelector::ComplexRendererFns
2550b57cec5SDimitry Andric   selectMUBUFScratchOffset(MachineOperand &Root) const;
2560b57cec5SDimitry Andric 
257e8d8bef9SDimitry Andric   bool isDSOffsetLegal(Register Base, int64_t Offset) const;
258e8d8bef9SDimitry Andric   bool isDSOffset2Legal(Register Base, int64_t Offset0, int64_t Offset1,
259e8d8bef9SDimitry Andric                         unsigned Size) const;
2605f757f3fSDimitry Andric   bool isFlatScratchBaseLegal(Register Addr) const;
2615f757f3fSDimitry Andric   bool isFlatScratchBaseLegalSV(Register Addr) const;
2625f757f3fSDimitry Andric   bool isFlatScratchBaseLegalSVImm(Register Addr) const;
2638bcb0991SDimitry Andric 
2645ffd83dbSDimitry Andric   std::pair<Register, unsigned>
2655ffd83dbSDimitry Andric   selectDS1Addr1OffsetImpl(MachineOperand &Root) const;
2668bcb0991SDimitry Andric   InstructionSelector::ComplexRendererFns
2678bcb0991SDimitry Andric   selectDS1Addr1Offset(MachineOperand &Root) const;
2688bcb0991SDimitry Andric 
2695ffd83dbSDimitry Andric   InstructionSelector::ComplexRendererFns
2705ffd83dbSDimitry Andric   selectDS64Bit4ByteAligned(MachineOperand &Root) const;
2715ffd83dbSDimitry Andric 
272e8d8bef9SDimitry Andric   InstructionSelector::ComplexRendererFns
273e8d8bef9SDimitry Andric   selectDS128Bit8ByteAligned(MachineOperand &Root) const;
274e8d8bef9SDimitry Andric 
275e8d8bef9SDimitry Andric   std::pair<Register, unsigned> selectDSReadWrite2Impl(MachineOperand &Root,
276e8d8bef9SDimitry Andric                                                        unsigned size) const;
277e8d8bef9SDimitry Andric   InstructionSelector::ComplexRendererFns
278e8d8bef9SDimitry Andric   selectDSReadWrite2(MachineOperand &Root, unsigned size) const;
279e8d8bef9SDimitry Andric 
2805ffd83dbSDimitry Andric   std::pair<Register, int64_t>
2815ffd83dbSDimitry Andric   getPtrBaseWithConstantOffset(Register Root,
2825ffd83dbSDimitry Andric                                const MachineRegisterInfo &MRI) const;
2835ffd83dbSDimitry Andric 
2845ffd83dbSDimitry Andric   // Parse out a chain of up to two g_ptr_add instructions.
2855ffd83dbSDimitry Andric   // g_ptr_add (n0, _)
2865ffd83dbSDimitry Andric   // g_ptr_add (n0, (n1 = g_ptr_add n2, n3))
2875ffd83dbSDimitry Andric   struct MUBUFAddressData {
2885ffd83dbSDimitry Andric     Register N0, N2, N3;
2895ffd83dbSDimitry Andric     int64_t Offset = 0;
2905ffd83dbSDimitry Andric   };
2915ffd83dbSDimitry Andric 
2925ffd83dbSDimitry Andric   bool shouldUseAddr64(MUBUFAddressData AddrData) const;
2935ffd83dbSDimitry Andric 
2945ffd83dbSDimitry Andric   void splitIllegalMUBUFOffset(MachineIRBuilder &B,
2955ffd83dbSDimitry Andric                                Register &SOffset, int64_t &ImmOffset) const;
2965ffd83dbSDimitry Andric 
2975ffd83dbSDimitry Andric   MUBUFAddressData parseMUBUFAddress(Register Src) const;
2985ffd83dbSDimitry Andric 
2995ffd83dbSDimitry Andric   bool selectMUBUFAddr64Impl(MachineOperand &Root, Register &VAddr,
3005ffd83dbSDimitry Andric                              Register &RSrcReg, Register &SOffset,
3015ffd83dbSDimitry Andric                              int64_t &Offset) const;
3025ffd83dbSDimitry Andric 
3035ffd83dbSDimitry Andric   bool selectMUBUFOffsetImpl(MachineOperand &Root, Register &RSrcReg,
3045ffd83dbSDimitry Andric                              Register &SOffset, int64_t &Offset) const;
3055ffd83dbSDimitry Andric 
3065ffd83dbSDimitry Andric   InstructionSelector::ComplexRendererFns
3075f757f3fSDimitry Andric   selectBUFSOffset(MachineOperand &Root) const;
3085f757f3fSDimitry Andric 
3095f757f3fSDimitry Andric   InstructionSelector::ComplexRendererFns
3105ffd83dbSDimitry Andric   selectMUBUFAddr64(MachineOperand &Root) const;
3115ffd83dbSDimitry Andric 
3125ffd83dbSDimitry Andric   InstructionSelector::ComplexRendererFns
3135ffd83dbSDimitry Andric   selectMUBUFOffset(MachineOperand &Root) const;
3145ffd83dbSDimitry Andric 
3155ffd83dbSDimitry Andric   ComplexRendererFns selectSMRDBufferImm(MachineOperand &Root) const;
3165ffd83dbSDimitry Andric   ComplexRendererFns selectSMRDBufferImm32(MachineOperand &Root) const;
317bdd1243dSDimitry Andric   ComplexRendererFns selectSMRDBufferSgprImm(MachineOperand &Root) const;
318bdd1243dSDimitry Andric 
319bdd1243dSDimitry Andric   std::pair<Register, unsigned> selectVOP3PMadMixModsImpl(MachineOperand &Root,
320bdd1243dSDimitry Andric                                                           bool &Matched) const;
32106c3fb27SDimitry Andric   ComplexRendererFns selectVOP3PMadMixModsExt(MachineOperand &Root) const;
322bdd1243dSDimitry Andric   ComplexRendererFns selectVOP3PMadMixMods(MachineOperand &Root) const;
3235ffd83dbSDimitry Andric 
324480093f4SDimitry Andric   void renderTruncImm32(MachineInstrBuilder &MIB, const MachineInstr &MI,
325480093f4SDimitry Andric                         int OpIdx = -1) const;
326480093f4SDimitry Andric 
327480093f4SDimitry Andric   void renderTruncTImm(MachineInstrBuilder &MIB, const MachineInstr &MI,
328480093f4SDimitry Andric                        int OpIdx) const;
329480093f4SDimitry Andric 
33006c3fb27SDimitry Andric   void renderOpSelTImm(MachineInstrBuilder &MIB, const MachineInstr &MI,
33106c3fb27SDimitry Andric                        int OpIdx) const;
33206c3fb27SDimitry Andric 
333480093f4SDimitry Andric   void renderNegateImm(MachineInstrBuilder &MIB, const MachineInstr &MI,
334480093f4SDimitry Andric                        int OpIdx) const;
335480093f4SDimitry Andric 
336480093f4SDimitry Andric   void renderBitcastImm(MachineInstrBuilder &MIB, const MachineInstr &MI,
337480093f4SDimitry Andric                         int OpIdx) const;
338480093f4SDimitry Andric 
339480093f4SDimitry Andric   void renderPopcntImm(MachineInstrBuilder &MIB, const MachineInstr &MI,
340480093f4SDimitry Andric                        int OpIdx) const;
341fe6060f1SDimitry Andric   void renderExtractCPol(MachineInstrBuilder &MIB, const MachineInstr &MI,
3425ffd83dbSDimitry Andric                          int OpIdx) const;
3435ffd83dbSDimitry Andric   void renderExtractSWZ(MachineInstrBuilder &MIB, const MachineInstr &MI,
3445ffd83dbSDimitry Andric                         int OpIdx) const;
3457a6dacacSDimitry Andric   void renderExtractCpolSetGLC(MachineInstrBuilder &MIB, const MachineInstr &MI,
346fe6060f1SDimitry Andric                                int OpIdx) const;
347fe6060f1SDimitry Andric 
348e8d8bef9SDimitry Andric   void renderFrameIndex(MachineInstrBuilder &MIB, const MachineInstr &MI,
349e8d8bef9SDimitry Andric                         int OpIdx) const;
350480093f4SDimitry Andric 
3515f757f3fSDimitry Andric   void renderFPPow2ToExponent(MachineInstrBuilder &MIB, const MachineInstr &MI,
3525f757f3fSDimitry Andric                               int OpIdx) const;
3535f757f3fSDimitry Andric 
354*0fca6ea1SDimitry Andric   bool isInlineImmediate(const APInt &Imm) const;
355480093f4SDimitry Andric   bool isInlineImmediate(const APFloat &Imm) const;
3568bcb0991SDimitry Andric 
3574824e7fdSDimitry Andric   // Returns true if TargetOpcode::G_AND MachineInstr `MI`'s masking of the
3584824e7fdSDimitry Andric   // shift amount operand's `ShAmtBits` bits is unneeded.
3594824e7fdSDimitry Andric   bool isUnneededShiftMask(const MachineInstr &MI, unsigned ShAmtBits) const;
3604824e7fdSDimitry Andric 
3610b57cec5SDimitry Andric   const SIInstrInfo &TII;
3620b57cec5SDimitry Andric   const SIRegisterInfo &TRI;
3630b57cec5SDimitry Andric   const AMDGPURegisterBankInfo &RBI;
3640b57cec5SDimitry Andric   const AMDGPUTargetMachine &TM;
3650b57cec5SDimitry Andric   const GCNSubtarget &STI;
3660b57cec5SDimitry Andric   bool EnableLateStructurizeCFG;
3670b57cec5SDimitry Andric #define GET_GLOBALISEL_PREDICATES_DECL
3680b57cec5SDimitry Andric #define AMDGPUSubtarget GCNSubtarget
3690b57cec5SDimitry Andric #include "AMDGPUGenGlobalISel.inc"
3700b57cec5SDimitry Andric #undef GET_GLOBALISEL_PREDICATES_DECL
3710b57cec5SDimitry Andric #undef AMDGPUSubtarget
3720b57cec5SDimitry Andric 
3730b57cec5SDimitry Andric #define GET_GLOBALISEL_TEMPORARIES_DECL
3740b57cec5SDimitry Andric #include "AMDGPUGenGlobalISel.inc"
3750b57cec5SDimitry Andric #undef GET_GLOBALISEL_TEMPORARIES_DECL
3760b57cec5SDimitry Andric };
3770b57cec5SDimitry Andric 
3780b57cec5SDimitry Andric } // End llvm namespace.
3790b57cec5SDimitry Andric #endif
380