xref: /aosp_15_r20/external/llvm/lib/Target/AMDGPU/SIISelLowering.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===-- SIISelLowering.h - SI DAG Lowering Interface ------------*- C++ -*-===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker /// \file
11*9880d681SAndroid Build Coastguard Worker /// \brief SI DAG Lowering interface definition
12*9880d681SAndroid Build Coastguard Worker //
13*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
14*9880d681SAndroid Build Coastguard Worker 
15*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_AMDGPU_SIISELLOWERING_H
16*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_AMDGPU_SIISELLOWERING_H
17*9880d681SAndroid Build Coastguard Worker 
18*9880d681SAndroid Build Coastguard Worker #include "AMDGPUISelLowering.h"
19*9880d681SAndroid Build Coastguard Worker #include "SIInstrInfo.h"
20*9880d681SAndroid Build Coastguard Worker 
21*9880d681SAndroid Build Coastguard Worker namespace llvm {
22*9880d681SAndroid Build Coastguard Worker 
23*9880d681SAndroid Build Coastguard Worker class SITargetLowering final : public AMDGPUTargetLowering {
24*9880d681SAndroid Build Coastguard Worker   SDValue LowerParameterPtr(SelectionDAG &DAG, const SDLoc &SL, SDValue Chain,
25*9880d681SAndroid Build Coastguard Worker                             unsigned Offset) const;
26*9880d681SAndroid Build Coastguard Worker   SDValue LowerParameter(SelectionDAG &DAG, EVT VT, EVT MemVT, const SDLoc &SL,
27*9880d681SAndroid Build Coastguard Worker                          SDValue Chain, unsigned Offset, bool Signed) const;
28*9880d681SAndroid Build Coastguard Worker   SDValue LowerGlobalAddress(AMDGPUMachineFunction *MFI, SDValue Op,
29*9880d681SAndroid Build Coastguard Worker                              SelectionDAG &DAG) const override;
30*9880d681SAndroid Build Coastguard Worker   SDValue lowerImplicitZextParam(SelectionDAG &DAG, SDValue Op,
31*9880d681SAndroid Build Coastguard Worker                                  MVT VT, unsigned Offset) const;
32*9880d681SAndroid Build Coastguard Worker 
33*9880d681SAndroid Build Coastguard Worker   SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
34*9880d681SAndroid Build Coastguard Worker   SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const;
35*9880d681SAndroid Build Coastguard Worker   SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
36*9880d681SAndroid Build Coastguard Worker   SDValue LowerFrameIndex(SDValue Op, SelectionDAG &DAG) const;
37*9880d681SAndroid Build Coastguard Worker   SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
38*9880d681SAndroid Build Coastguard Worker   SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
39*9880d681SAndroid Build Coastguard Worker   SDValue LowerFastFDIV(SDValue Op, SelectionDAG &DAG) const;
40*9880d681SAndroid Build Coastguard Worker   SDValue LowerFDIV32(SDValue Op, SelectionDAG &DAG) const;
41*9880d681SAndroid Build Coastguard Worker   SDValue LowerFDIV64(SDValue Op, SelectionDAG &DAG) const;
42*9880d681SAndroid Build Coastguard Worker   SDValue LowerFDIV(SDValue Op, SelectionDAG &DAG) const;
43*9880d681SAndroid Build Coastguard Worker   SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG, bool Signed) const;
44*9880d681SAndroid Build Coastguard Worker   SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
45*9880d681SAndroid Build Coastguard Worker   SDValue LowerTrig(SDValue Op, SelectionDAG &DAG) const;
46*9880d681SAndroid Build Coastguard Worker   SDValue LowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const;
47*9880d681SAndroid Build Coastguard Worker   SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
48*9880d681SAndroid Build Coastguard Worker 
49*9880d681SAndroid Build Coastguard Worker   SDValue getSegmentAperture(unsigned AS, SelectionDAG &DAG) const;
50*9880d681SAndroid Build Coastguard Worker   SDValue lowerADDRSPACECAST(SDValue Op, SelectionDAG &DAG) const;
51*9880d681SAndroid Build Coastguard Worker   SDValue lowerTRAP(SDValue Op, SelectionDAG &DAG) const;
52*9880d681SAndroid Build Coastguard Worker 
53*9880d681SAndroid Build Coastguard Worker   void adjustWritemask(MachineSDNode *&N, SelectionDAG &DAG) const;
54*9880d681SAndroid Build Coastguard Worker 
55*9880d681SAndroid Build Coastguard Worker   SDValue performUCharToFloatCombine(SDNode *N,
56*9880d681SAndroid Build Coastguard Worker                                      DAGCombinerInfo &DCI) const;
57*9880d681SAndroid Build Coastguard Worker   SDValue performSHLPtrCombine(SDNode *N,
58*9880d681SAndroid Build Coastguard Worker                                unsigned AS,
59*9880d681SAndroid Build Coastguard Worker                                DAGCombinerInfo &DCI) const;
60*9880d681SAndroid Build Coastguard Worker   SDValue performAndCombine(SDNode *N, DAGCombinerInfo &DCI) const;
61*9880d681SAndroid Build Coastguard Worker   SDValue performOrCombine(SDNode *N, DAGCombinerInfo &DCI) const;
62*9880d681SAndroid Build Coastguard Worker   SDValue performClassCombine(SDNode *N, DAGCombinerInfo &DCI) const;
63*9880d681SAndroid Build Coastguard Worker   SDValue performFCanonicalizeCombine(SDNode *N, DAGCombinerInfo &DCI) const;
64*9880d681SAndroid Build Coastguard Worker 
65*9880d681SAndroid Build Coastguard Worker   SDValue performMinMaxCombine(SDNode *N, DAGCombinerInfo &DCI) const;
66*9880d681SAndroid Build Coastguard Worker 
67*9880d681SAndroid Build Coastguard Worker   SDValue performSetCCCombine(SDNode *N, DAGCombinerInfo &DCI) const;
68*9880d681SAndroid Build Coastguard Worker 
69*9880d681SAndroid Build Coastguard Worker   bool isLegalFlatAddressingMode(const AddrMode &AM) const;
70*9880d681SAndroid Build Coastguard Worker   bool isLegalMUBUFAddressingMode(const AddrMode &AM) const;
71*9880d681SAndroid Build Coastguard Worker 
72*9880d681SAndroid Build Coastguard Worker   bool isCFIntrinsic(const SDNode *Intr) const;
73*9880d681SAndroid Build Coastguard Worker 
74*9880d681SAndroid Build Coastguard Worker   void createDebuggerPrologueStackObjects(MachineFunction &MF) const;
75*9880d681SAndroid Build Coastguard Worker public:
76*9880d681SAndroid Build Coastguard Worker   SITargetLowering(const TargetMachine &tm, const SISubtarget &STI);
77*9880d681SAndroid Build Coastguard Worker 
78*9880d681SAndroid Build Coastguard Worker   const SISubtarget *getSubtarget() const;
79*9880d681SAndroid Build Coastguard Worker 
80*9880d681SAndroid Build Coastguard Worker   bool getTgtMemIntrinsic(IntrinsicInfo &, const CallInst &,
81*9880d681SAndroid Build Coastguard Worker                           unsigned IntrinsicID) const override;
82*9880d681SAndroid Build Coastguard Worker 
83*9880d681SAndroid Build Coastguard Worker   bool isShuffleMaskLegal(const SmallVectorImpl<int> &/*Mask*/,
84*9880d681SAndroid Build Coastguard Worker                           EVT /*VT*/) const override;
85*9880d681SAndroid Build Coastguard Worker 
86*9880d681SAndroid Build Coastguard Worker   bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
87*9880d681SAndroid Build Coastguard Worker                              unsigned AS) const override;
88*9880d681SAndroid Build Coastguard Worker 
89*9880d681SAndroid Build Coastguard Worker   bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS,
90*9880d681SAndroid Build Coastguard Worker                                       unsigned Align,
91*9880d681SAndroid Build Coastguard Worker                                       bool *IsFast) const override;
92*9880d681SAndroid Build Coastguard Worker 
93*9880d681SAndroid Build Coastguard Worker   EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign,
94*9880d681SAndroid Build Coastguard Worker                           unsigned SrcAlign, bool IsMemset,
95*9880d681SAndroid Build Coastguard Worker                           bool ZeroMemset,
96*9880d681SAndroid Build Coastguard Worker                           bool MemcpyStrSrc,
97*9880d681SAndroid Build Coastguard Worker                           MachineFunction &MF) const override;
98*9880d681SAndroid Build Coastguard Worker 
99*9880d681SAndroid Build Coastguard Worker   bool isMemOpUniform(const SDNode *N) const;
100*9880d681SAndroid Build Coastguard Worker   bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override;
101*9880d681SAndroid Build Coastguard Worker 
102*9880d681SAndroid Build Coastguard Worker   TargetLoweringBase::LegalizeTypeAction
103*9880d681SAndroid Build Coastguard Worker   getPreferredVectorAction(EVT VT) const override;
104*9880d681SAndroid Build Coastguard Worker 
105*9880d681SAndroid Build Coastguard Worker   bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
106*9880d681SAndroid Build Coastguard Worker                                         Type *Ty) const override;
107*9880d681SAndroid Build Coastguard Worker 
108*9880d681SAndroid Build Coastguard Worker   bool isTypeDesirableForOp(unsigned Op, EVT VT) const override;
109*9880d681SAndroid Build Coastguard Worker 
110*9880d681SAndroid Build Coastguard Worker   bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
111*9880d681SAndroid Build Coastguard Worker 
112*9880d681SAndroid Build Coastguard Worker   SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
113*9880d681SAndroid Build Coastguard Worker                                bool isVarArg,
114*9880d681SAndroid Build Coastguard Worker                                const SmallVectorImpl<ISD::InputArg> &Ins,
115*9880d681SAndroid Build Coastguard Worker                                const SDLoc &DL, SelectionDAG &DAG,
116*9880d681SAndroid Build Coastguard Worker                                SmallVectorImpl<SDValue> &InVals) const override;
117*9880d681SAndroid Build Coastguard Worker 
118*9880d681SAndroid Build Coastguard Worker   SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
119*9880d681SAndroid Build Coastguard Worker                       const SmallVectorImpl<ISD::OutputArg> &Outs,
120*9880d681SAndroid Build Coastguard Worker                       const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
121*9880d681SAndroid Build Coastguard Worker                       SelectionDAG &DAG) const override;
122*9880d681SAndroid Build Coastguard Worker 
123*9880d681SAndroid Build Coastguard Worker   unsigned getRegisterByName(const char* RegName, EVT VT,
124*9880d681SAndroid Build Coastguard Worker                              SelectionDAG &DAG) const override;
125*9880d681SAndroid Build Coastguard Worker 
126*9880d681SAndroid Build Coastguard Worker   MachineBasicBlock *splitKillBlock(MachineInstr &MI,
127*9880d681SAndroid Build Coastguard Worker                                     MachineBasicBlock *BB) const;
128*9880d681SAndroid Build Coastguard Worker 
129*9880d681SAndroid Build Coastguard Worker   MachineBasicBlock *
130*9880d681SAndroid Build Coastguard Worker   EmitInstrWithCustomInserter(MachineInstr &MI,
131*9880d681SAndroid Build Coastguard Worker                               MachineBasicBlock *BB) const override;
132*9880d681SAndroid Build Coastguard Worker   bool enableAggressiveFMAFusion(EVT VT) const override;
133*9880d681SAndroid Build Coastguard Worker   EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
134*9880d681SAndroid Build Coastguard Worker                          EVT VT) const override;
135*9880d681SAndroid Build Coastguard Worker   MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override;
136*9880d681SAndroid Build Coastguard Worker   bool isFMAFasterThanFMulAndFAdd(EVT VT) const override;
137*9880d681SAndroid Build Coastguard Worker   SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
138*9880d681SAndroid Build Coastguard Worker   SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
139*9880d681SAndroid Build Coastguard Worker   SDNode *PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const override;
140*9880d681SAndroid Build Coastguard Worker   void AdjustInstrPostInstrSelection(MachineInstr &MI,
141*9880d681SAndroid Build Coastguard Worker                                      SDNode *Node) const override;
142*9880d681SAndroid Build Coastguard Worker 
143*9880d681SAndroid Build Coastguard Worker   int32_t analyzeImmediate(const SDNode *N) const;
144*9880d681SAndroid Build Coastguard Worker   SDValue CreateLiveInRegister(SelectionDAG &DAG, const TargetRegisterClass *RC,
145*9880d681SAndroid Build Coastguard Worker                                unsigned Reg, EVT VT) const override;
146*9880d681SAndroid Build Coastguard Worker   void legalizeTargetIndependentNode(SDNode *Node, SelectionDAG &DAG) const;
147*9880d681SAndroid Build Coastguard Worker 
148*9880d681SAndroid Build Coastguard Worker   MachineSDNode *wrapAddr64Rsrc(SelectionDAG &DAG, const SDLoc &DL,
149*9880d681SAndroid Build Coastguard Worker                                 SDValue Ptr) const;
150*9880d681SAndroid Build Coastguard Worker   MachineSDNode *buildRSRC(SelectionDAG &DAG, const SDLoc &DL, SDValue Ptr,
151*9880d681SAndroid Build Coastguard Worker                            uint32_t RsrcDword1, uint64_t RsrcDword2And3) const;
152*9880d681SAndroid Build Coastguard Worker   std::pair<unsigned, const TargetRegisterClass *>
153*9880d681SAndroid Build Coastguard Worker   getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
154*9880d681SAndroid Build Coastguard Worker                                StringRef Constraint, MVT VT) const override;
155*9880d681SAndroid Build Coastguard Worker   ConstraintType getConstraintType(StringRef Constraint) const override;
156*9880d681SAndroid Build Coastguard Worker   SDValue copyToM0(SelectionDAG &DAG, SDValue Chain, const SDLoc &DL,
157*9880d681SAndroid Build Coastguard Worker                    SDValue V) const;
158*9880d681SAndroid Build Coastguard Worker };
159*9880d681SAndroid Build Coastguard Worker 
160*9880d681SAndroid Build Coastguard Worker } // End namespace llvm
161*9880d681SAndroid Build Coastguard Worker 
162*9880d681SAndroid Build Coastguard Worker #endif
163