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