]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/AMDGPU/SIISelLowering.h
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r304460, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / AMDGPU / SIISelLowering.h
1 //===-- SIISelLowering.h - SI DAG Lowering Interface ------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 /// \file
11 /// \brief SI DAG Lowering interface definition
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_LIB_TARGET_AMDGPU_SIISELLOWERING_H
16 #define LLVM_LIB_TARGET_AMDGPU_SIISELLOWERING_H
17
18 #include "AMDGPUISelLowering.h"
19 #include "SIInstrInfo.h"
20
21 namespace llvm {
22
23 class SITargetLowering final : public AMDGPUTargetLowering {
24   SDValue lowerKernArgParameterPtr(SelectionDAG &DAG, const SDLoc &SL,
25                                    SDValue Chain, uint64_t Offset) const;
26   SDValue lowerKernargMemParameter(SelectionDAG &DAG, EVT VT, EVT MemVT,
27                                    const SDLoc &SL, SDValue Chain,
28                                    uint64_t Offset, bool Signed,
29                                    const ISD::InputArg *Arg = nullptr) const;
30
31   SDValue lowerStackParameter(SelectionDAG &DAG, CCValAssign &VA,
32                               const SDLoc &SL, SDValue Chain,
33                               const ISD::InputArg &Arg) const;
34
35   SDValue LowerGlobalAddress(AMDGPUMachineFunction *MFI, SDValue Op,
36                              SelectionDAG &DAG) const override;
37   SDValue lowerImplicitZextParam(SelectionDAG &DAG, SDValue Op,
38                                  MVT VT, unsigned Offset) const;
39
40   SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
41   SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const;
42   SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
43   SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
44   SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
45   SDValue lowerFastUnsafeFDIV(SDValue Op, SelectionDAG &DAG) const;
46   SDValue lowerFDIV_FAST(SDValue Op, SelectionDAG &DAG) const;
47   SDValue LowerFDIV16(SDValue Op, SelectionDAG &DAG) const;
48   SDValue LowerFDIV32(SDValue Op, SelectionDAG &DAG) const;
49   SDValue LowerFDIV64(SDValue Op, SelectionDAG &DAG) const;
50   SDValue LowerFDIV(SDValue Op, SelectionDAG &DAG) const;
51   SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG, bool Signed) const;
52   SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
53   SDValue LowerTrig(SDValue Op, SelectionDAG &DAG) const;
54   SDValue LowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const;
55   SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
56
57   /// \brief Converts \p Op, which must be of floating point type, to the
58   /// floating point type \p VT, by either extending or truncating it.
59   SDValue getFPExtOrFPTrunc(SelectionDAG &DAG,
60                             SDValue Op,
61                             const SDLoc &DL,
62                             EVT VT) const;
63
64   SDValue convertArgType(
65     SelectionDAG &DAG, EVT VT, EVT MemVT, const SDLoc &SL, SDValue Val,
66     bool Signed, const ISD::InputArg *Arg = nullptr) const;
67
68   /// \brief Custom lowering for ISD::FP_ROUND for MVT::f16.
69   SDValue lowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
70
71   SDValue getSegmentAperture(unsigned AS, const SDLoc &DL,
72                              SelectionDAG &DAG) const;
73
74   SDValue lowerADDRSPACECAST(SDValue Op, SelectionDAG &DAG) const;
75   SDValue lowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
76   SDValue lowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
77   SDValue lowerTRAP(SDValue Op, SelectionDAG &DAG) const;
78
79   void adjustWritemask(MachineSDNode *&N, SelectionDAG &DAG) const;
80
81   SDValue performUCharToFloatCombine(SDNode *N,
82                                      DAGCombinerInfo &DCI) const;
83   SDValue performSHLPtrCombine(SDNode *N,
84                                unsigned AS,
85                                DAGCombinerInfo &DCI) const;
86
87   SDValue performMemSDNodeCombine(MemSDNode *N, DAGCombinerInfo &DCI) const;
88
89   SDValue splitBinaryBitConstantOp(DAGCombinerInfo &DCI, const SDLoc &SL,
90                                    unsigned Opc, SDValue LHS,
91                                    const ConstantSDNode *CRHS) const;
92
93   SDValue performAndCombine(SDNode *N, DAGCombinerInfo &DCI) const;
94   SDValue performOrCombine(SDNode *N, DAGCombinerInfo &DCI) const;
95   SDValue performXorCombine(SDNode *N, DAGCombinerInfo &DCI) const;
96   SDValue performZeroExtendCombine(SDNode *N, DAGCombinerInfo &DCI) const;
97   SDValue performClassCombine(SDNode *N, DAGCombinerInfo &DCI) const;
98   SDValue performFCanonicalizeCombine(SDNode *N, DAGCombinerInfo &DCI) const;
99
100   SDValue performFPMed3ImmCombine(SelectionDAG &DAG, const SDLoc &SL,
101                                   SDValue Op0, SDValue Op1) const;
102   SDValue performIntMed3ImmCombine(SelectionDAG &DAG, const SDLoc &SL,
103                                    SDValue Op0, SDValue Op1, bool Signed) const;
104   SDValue performMinMaxCombine(SDNode *N, DAGCombinerInfo &DCI) const;
105   SDValue performFMed3Combine(SDNode *N, DAGCombinerInfo &DCI) const;
106   SDValue performCvtPkRTZCombine(SDNode *N, DAGCombinerInfo &DCI) const;
107   SDValue performExtractVectorEltCombine(SDNode *N, DAGCombinerInfo &DCI) const;
108
109   unsigned getFusedOpcode(const SelectionDAG &DAG,
110                           const SDNode *N0, const SDNode *N1) const;
111   SDValue performFAddCombine(SDNode *N, DAGCombinerInfo &DCI) const;
112   SDValue performFSubCombine(SDNode *N, DAGCombinerInfo &DCI) const;
113   SDValue performSetCCCombine(SDNode *N, DAGCombinerInfo &DCI) const;
114   SDValue performCvtF32UByteNCombine(SDNode *N, DAGCombinerInfo &DCI) const;
115
116   bool isLegalFlatAddressingMode(const AddrMode &AM) const;
117   bool isLegalMUBUFAddressingMode(const AddrMode &AM) const;
118
119   unsigned isCFIntrinsic(const SDNode *Intr) const;
120
121   void createDebuggerPrologueStackObjects(MachineFunction &MF) const;
122
123   /// \returns True if fixup needs to be emitted for given global value \p GV,
124   /// false otherwise.
125   bool shouldEmitFixup(const GlobalValue *GV) const;
126
127   /// \returns True if GOT relocation needs to be emitted for given global value
128   /// \p GV, false otherwise.
129   bool shouldEmitGOTReloc(const GlobalValue *GV) const;
130
131   /// \returns True if PC-relative relocation needs to be emitted for given
132   /// global value \p GV, false otherwise.
133   bool shouldEmitPCReloc(const GlobalValue *GV) const;
134
135 public:
136   SITargetLowering(const TargetMachine &tm, const SISubtarget &STI);
137
138   const SISubtarget *getSubtarget() const;
139
140   bool isShuffleMaskLegal(const SmallVectorImpl<int> &/*Mask*/,
141                           EVT /*VT*/) const override;
142
143   bool getTgtMemIntrinsic(IntrinsicInfo &, const CallInst &,
144                           unsigned IntrinsicID) const override;
145
146   bool getAddrModeArguments(IntrinsicInst * /*I*/,
147                             SmallVectorImpl<Value*> &/*Ops*/,
148                             Type *&/*AccessTy*/) const override;
149
150   bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
151                              unsigned AS) const override;
152
153   bool canMergeStoresTo(unsigned AS, EVT MemVT) const override;
154
155   bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS,
156                                       unsigned Align,
157                                       bool *IsFast) const override;
158
159   EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign,
160                           unsigned SrcAlign, bool IsMemset,
161                           bool ZeroMemset,
162                           bool MemcpyStrSrc,
163                           MachineFunction &MF) const override;
164
165   bool isMemOpUniform(const SDNode *N) const;
166   bool isMemOpHasNoClobberedMemOperand(const SDNode *N) const;
167   bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override;
168   bool isCheapAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override;
169
170   TargetLoweringBase::LegalizeTypeAction
171   getPreferredVectorAction(EVT VT) const override;
172
173   bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
174                                         Type *Ty) const override;
175
176   bool isTypeDesirableForOp(unsigned Op, EVT VT) const override;
177
178   bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
179
180   SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
181                                bool isVarArg,
182                                const SmallVectorImpl<ISD::InputArg> &Ins,
183                                const SDLoc &DL, SelectionDAG &DAG,
184                                SmallVectorImpl<SDValue> &InVals) const override;
185
186   bool CanLowerReturn(CallingConv::ID CallConv,
187                       MachineFunction &MF, bool isVarArg,
188                       const SmallVectorImpl<ISD::OutputArg> &Outs,
189                       LLVMContext &Context) const override;
190
191   SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
192                       const SmallVectorImpl<ISD::OutputArg> &Outs,
193                       const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
194                       SelectionDAG &DAG) const override;
195
196   unsigned getRegisterByName(const char* RegName, EVT VT,
197                              SelectionDAG &DAG) const override;
198
199   MachineBasicBlock *splitKillBlock(MachineInstr &MI,
200                                     MachineBasicBlock *BB) const;
201
202   MachineBasicBlock *
203   EmitInstrWithCustomInserter(MachineInstr &MI,
204                               MachineBasicBlock *BB) const override;
205   bool enableAggressiveFMAFusion(EVT VT) const override;
206   EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
207                          EVT VT) const override;
208   MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override;
209   bool isFMAFasterThanFMulAndFAdd(EVT VT) const override;
210   SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
211   void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
212                           SelectionDAG &DAG) const override;
213
214   SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
215   SDNode *PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const override;
216   void AdjustInstrPostInstrSelection(MachineInstr &MI,
217                                      SDNode *Node) const override;
218
219   SDValue CreateLiveInRegister(SelectionDAG &DAG, const TargetRegisterClass *RC,
220                                unsigned Reg, EVT VT) const override;
221   SDNode *legalizeTargetIndependentNode(SDNode *Node, SelectionDAG &DAG) const;
222
223   MachineSDNode *wrapAddr64Rsrc(SelectionDAG &DAG, const SDLoc &DL,
224                                 SDValue Ptr) const;
225   MachineSDNode *buildRSRC(SelectionDAG &DAG, const SDLoc &DL, SDValue Ptr,
226                            uint32_t RsrcDword1, uint64_t RsrcDword2And3) const;
227   std::pair<unsigned, const TargetRegisterClass *>
228   getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
229                                StringRef Constraint, MVT VT) const override;
230   ConstraintType getConstraintType(StringRef Constraint) const override;
231   SDValue copyToM0(SelectionDAG &DAG, SDValue Chain, const SDLoc &DL,
232                    SDValue V) const;
233 };
234
235 } // End namespace llvm
236
237 #endif