LCOV - code coverage report
Current view: top level - lib/Target/AMDGPU - SIISelLowering.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 1 1 100.0 %
Date: 2018-10-20 13:21:21 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       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             : /// 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 "AMDGPUArgumentUsageInfo.h"
      20             : #include "SIInstrInfo.h"
      21             : 
      22             : namespace llvm {
      23             : 
      24        2481 : class SITargetLowering final : public AMDGPUTargetLowering {
      25             : private:
      26             :   const GCNSubtarget *Subtarget;
      27             : 
      28             : public:
      29             :   MVT getRegisterTypeForCallingConv(LLVMContext &Context,
      30             :                                     CallingConv::ID CC,
      31             :                                     EVT VT) const override;
      32             :   unsigned getNumRegistersForCallingConv(LLVMContext &Context,
      33             :                                          CallingConv::ID CC,
      34             :                                          EVT VT) const override;
      35             : 
      36             :   unsigned getVectorTypeBreakdownForCallingConv(
      37             :     LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT,
      38             :     unsigned &NumIntermediates, MVT &RegisterVT) const override;
      39             : 
      40             : private:
      41             :   SDValue lowerKernArgParameterPtr(SelectionDAG &DAG, const SDLoc &SL,
      42             :                                    SDValue Chain, uint64_t Offset) const;
      43             :   SDValue getImplicitArgPtr(SelectionDAG &DAG, const SDLoc &SL) const;
      44             :   SDValue lowerKernargMemParameter(SelectionDAG &DAG, EVT VT, EVT MemVT,
      45             :                                    const SDLoc &SL, SDValue Chain,
      46             :                                    uint64_t Offset, unsigned Align, bool Signed,
      47             :                                    const ISD::InputArg *Arg = nullptr) const;
      48             : 
      49             :   SDValue lowerStackParameter(SelectionDAG &DAG, CCValAssign &VA,
      50             :                               const SDLoc &SL, SDValue Chain,
      51             :                               const ISD::InputArg &Arg) const;
      52             :   SDValue getPreloadedValue(SelectionDAG &DAG,
      53             :                             const SIMachineFunctionInfo &MFI,
      54             :                             EVT VT,
      55             :                             AMDGPUFunctionArgInfo::PreloadedValue) const;
      56             : 
      57             :   SDValue LowerGlobalAddress(AMDGPUMachineFunction *MFI, SDValue Op,
      58             :                              SelectionDAG &DAG) const override;
      59             :   SDValue lowerImplicitZextParam(SelectionDAG &DAG, SDValue Op,
      60             :                                  MVT VT, unsigned Offset) const;
      61             :   SDValue lowerImage(SDValue Op, const AMDGPU::ImageDimIntrinsicInfo *Intr,
      62             :                      SelectionDAG &DAG) const;
      63             :   SDValue lowerSBuffer(EVT VT, SDLoc DL, SDValue Rsrc, SDValue Offset,
      64             :                        SDValue GLC, SelectionDAG &DAG) const;
      65             : 
      66             :   SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
      67             :   SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const;
      68             :   SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
      69             : 
      70             :   // The raw.tbuffer and struct.tbuffer intrinsics have two offset args: offset
      71             :   // (the offset that is included in bounds checking and swizzling, to be split
      72             :   // between the instruction's voffset and immoffset fields) and soffset (the
      73             :   // offset that is excluded from bounds checking and swizzling, to go in the
      74             :   // instruction's soffset field).  This function takes the first kind of
      75             :   // offset and figures out how to split it between voffset and immoffset.
      76             :   std::pair<SDValue, SDValue> splitBufferOffsets(SDValue Offset,
      77             :                                                  SelectionDAG &DAG) const;
      78             : 
      79             :   SDValue widenLoad(LoadSDNode *Ld, DAGCombinerInfo &DCI) const;
      80             :   SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
      81             :   SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
      82             :   SDValue lowerFastUnsafeFDIV(SDValue Op, SelectionDAG &DAG) const;
      83             :   SDValue lowerFDIV_FAST(SDValue Op, SelectionDAG &DAG) const;
      84             :   SDValue LowerFDIV16(SDValue Op, SelectionDAG &DAG) const;
      85             :   SDValue LowerFDIV32(SDValue Op, SelectionDAG &DAG) const;
      86             :   SDValue LowerFDIV64(SDValue Op, SelectionDAG &DAG) const;
      87             :   SDValue LowerFDIV(SDValue Op, SelectionDAG &DAG) const;
      88             :   SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG, bool Signed) const;
      89             :   SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
      90             :   SDValue LowerTrig(SDValue Op, SelectionDAG &DAG) const;
      91             :   SDValue LowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const;
      92             :   SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
      93             : 
      94             :   SDValue adjustLoadValueType(unsigned Opcode, MemSDNode *M,
      95             :                               SelectionDAG &DAG, ArrayRef<SDValue> Ops,
      96             :                               bool IsIntrinsic = false) const;
      97             : 
      98             :   SDValue handleD16VData(SDValue VData, SelectionDAG &DAG) const;
      99             : 
     100             :   /// Converts \p Op, which must be of floating point type, to the
     101             :   /// floating point type \p VT, by either extending or truncating it.
     102             :   SDValue getFPExtOrFPTrunc(SelectionDAG &DAG,
     103             :                             SDValue Op,
     104             :                             const SDLoc &DL,
     105             :                             EVT VT) const;
     106             : 
     107             :   SDValue convertArgType(
     108             :     SelectionDAG &DAG, EVT VT, EVT MemVT, const SDLoc &SL, SDValue Val,
     109             :     bool Signed, const ISD::InputArg *Arg = nullptr) const;
     110             : 
     111             :   /// Custom lowering for ISD::FP_ROUND for MVT::f16.
     112             :   SDValue lowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
     113             : 
     114             :   SDValue getSegmentAperture(unsigned AS, const SDLoc &DL,
     115             :                              SelectionDAG &DAG) const;
     116             : 
     117             :   SDValue lowerADDRSPACECAST(SDValue Op, SelectionDAG &DAG) const;
     118             :   SDValue lowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
     119             :   SDValue lowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
     120             :   SDValue lowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
     121             :   SDValue lowerTRAP(SDValue Op, SelectionDAG &DAG) const;
     122             :   SDValue lowerDEBUGTRAP(SDValue Op, SelectionDAG &DAG) const;
     123             : 
     124             :   SDNode *adjustWritemask(MachineSDNode *&N, SelectionDAG &DAG) const;
     125             : 
     126             :   SDValue performUCharToFloatCombine(SDNode *N,
     127             :                                      DAGCombinerInfo &DCI) const;
     128             :   SDValue performSHLPtrCombine(SDNode *N,
     129             :                                unsigned AS,
     130             :                                EVT MemVT,
     131             :                                DAGCombinerInfo &DCI) const;
     132             : 
     133             :   SDValue performMemSDNodeCombine(MemSDNode *N, DAGCombinerInfo &DCI) const;
     134             : 
     135             :   SDValue splitBinaryBitConstantOp(DAGCombinerInfo &DCI, const SDLoc &SL,
     136             :                                    unsigned Opc, SDValue LHS,
     137             :                                    const ConstantSDNode *CRHS) const;
     138             : 
     139             :   SDValue performAndCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     140             :   SDValue performOrCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     141             :   SDValue performXorCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     142             :   SDValue performZeroExtendCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     143             :   SDValue performClassCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     144             :   SDValue getCanonicalConstantFP(SelectionDAG &DAG, const SDLoc &SL, EVT VT,
     145             :                                  const APFloat &C) const;
     146             :   SDValue performFCanonicalizeCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     147             : 
     148             :   SDValue performFPMed3ImmCombine(SelectionDAG &DAG, const SDLoc &SL,
     149             :                                   SDValue Op0, SDValue Op1) const;
     150             :   SDValue performIntMed3ImmCombine(SelectionDAG &DAG, const SDLoc &SL,
     151             :                                    SDValue Op0, SDValue Op1, bool Signed) const;
     152             :   SDValue performMinMaxCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     153             :   SDValue performFMed3Combine(SDNode *N, DAGCombinerInfo &DCI) const;
     154             :   SDValue performCvtPkRTZCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     155             :   SDValue performExtractVectorEltCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     156             :   SDValue performBuildVectorCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     157             : 
     158             :   unsigned getFusedOpcode(const SelectionDAG &DAG,
     159             :                           const SDNode *N0, const SDNode *N1) const;
     160             :   SDValue performAddCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     161             :   SDValue performAddCarrySubCarryCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     162             :   SDValue performSubCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     163             :   SDValue performFAddCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     164             :   SDValue performFSubCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     165             :   SDValue performFMACombine(SDNode *N, DAGCombinerInfo &DCI) const;
     166             :   SDValue performSetCCCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     167             :   SDValue performCvtF32UByteNCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     168             :   SDValue performClampCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     169             :   SDValue performRcpCombine(SDNode *N, DAGCombinerInfo &DCI) const;
     170             : 
     171             :   bool isLegalFlatAddressingMode(const AddrMode &AM) const;
     172             :   bool isLegalGlobalAddressingMode(const AddrMode &AM) const;
     173             :   bool isLegalMUBUFAddressingMode(const AddrMode &AM) const;
     174             : 
     175             :   unsigned isCFIntrinsic(const SDNode *Intr) const;
     176             : 
     177             :   void createDebuggerPrologueStackObjects(MachineFunction &MF) const;
     178             : 
     179             :   /// \returns True if fixup needs to be emitted for given global value \p GV,
     180             :   /// false otherwise.
     181             :   bool shouldEmitFixup(const GlobalValue *GV) const;
     182             : 
     183             :   /// \returns True if GOT relocation needs to be emitted for given global value
     184             :   /// \p GV, false otherwise.
     185             :   bool shouldEmitGOTReloc(const GlobalValue *GV) const;
     186             : 
     187             :   /// \returns True if PC-relative relocation needs to be emitted for given
     188             :   /// global value \p GV, false otherwise.
     189             :   bool shouldEmitPCReloc(const GlobalValue *GV) const;
     190             : 
     191             :   // Analyze a combined offset from an amdgcn_buffer_ intrinsic and store the
     192             :   // three offsets (voffset, soffset and instoffset) into the SDValue[3] array
     193             :   // pointed to by Offsets.
     194             :   void setBufferOffsets(SDValue CombinedOffset, SelectionDAG &DAG,
     195             :                         SDValue *Offsets, unsigned Align = 4) const;
     196             : 
     197             : public:
     198             :   SITargetLowering(const TargetMachine &tm, const GCNSubtarget &STI);
     199             : 
     200             :   const GCNSubtarget *getSubtarget() const;
     201             : 
     202             :   bool isFPExtFoldable(unsigned Opcode, EVT DestVT, EVT SrcVT) const override;
     203             : 
     204             :   bool isShuffleMaskLegal(ArrayRef<int> /*Mask*/, EVT /*VT*/) const override;
     205             : 
     206             :   bool getTgtMemIntrinsic(IntrinsicInfo &, const CallInst &,
     207             :                           MachineFunction &MF,
     208             :                           unsigned IntrinsicID) const override;
     209             : 
     210             :   bool getAddrModeArguments(IntrinsicInst * /*I*/,
     211             :                             SmallVectorImpl<Value*> &/*Ops*/,
     212             :                             Type *&/*AccessTy*/) const override;
     213             : 
     214             :   bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
     215             :                              unsigned AS,
     216             :                              Instruction *I = nullptr) const override;
     217             : 
     218             :   bool canMergeStoresTo(unsigned AS, EVT MemVT,
     219             :                         const SelectionDAG &DAG) const override;
     220             : 
     221             :   bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS,
     222             :                                       unsigned Align,
     223             :                                       bool *IsFast) const override;
     224             : 
     225             :   EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign,
     226             :                           unsigned SrcAlign, bool IsMemset,
     227             :                           bool ZeroMemset,
     228             :                           bool MemcpyStrSrc,
     229             :                           MachineFunction &MF) const override;
     230             : 
     231             :   bool isMemOpUniform(const SDNode *N) const;
     232             :   bool isMemOpHasNoClobberedMemOperand(const SDNode *N) const;
     233             :   bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override;
     234             :   bool isCheapAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override;
     235             : 
     236             :   TargetLoweringBase::LegalizeTypeAction
     237             :   getPreferredVectorAction(EVT VT) const override;
     238             : 
     239             :   bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
     240             :                                         Type *Ty) const override;
     241             : 
     242             :   bool isTypeDesirableForOp(unsigned Op, EVT VT) const override;
     243             : 
     244             :   bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
     245             : 
     246             :   bool supportSplitCSR(MachineFunction *MF) const override;
     247             :   void initializeSplitCSR(MachineBasicBlock *Entry) const override;
     248             :   void insertCopiesSplitCSR(
     249             :     MachineBasicBlock *Entry,
     250             :     const SmallVectorImpl<MachineBasicBlock *> &Exits) const override;
     251             : 
     252             :   SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
     253             :                                bool isVarArg,
     254             :                                const SmallVectorImpl<ISD::InputArg> &Ins,
     255             :                                const SDLoc &DL, SelectionDAG &DAG,
     256             :                                SmallVectorImpl<SDValue> &InVals) const override;
     257             : 
     258             :   bool CanLowerReturn(CallingConv::ID CallConv,
     259             :                       MachineFunction &MF, bool isVarArg,
     260             :                       const SmallVectorImpl<ISD::OutputArg> &Outs,
     261             :                       LLVMContext &Context) const override;
     262             : 
     263             :   SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
     264             :                       const SmallVectorImpl<ISD::OutputArg> &Outs,
     265             :                       const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
     266             :                       SelectionDAG &DAG) const override;
     267             : 
     268             :   void passSpecialInputs(
     269             :     CallLoweringInfo &CLI,
     270             :     CCState &CCInfo,
     271             :     const SIMachineFunctionInfo &Info,
     272             :     SmallVectorImpl<std::pair<unsigned, SDValue>> &RegsToPass,
     273             :     SmallVectorImpl<SDValue> &MemOpChains,
     274             :     SDValue Chain) const;
     275             : 
     276             :   SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
     277             :                           CallingConv::ID CallConv, bool isVarArg,
     278             :                           const SmallVectorImpl<ISD::InputArg> &Ins,
     279             :                           const SDLoc &DL, SelectionDAG &DAG,
     280             :                           SmallVectorImpl<SDValue> &InVals, bool isThisReturn,
     281             :                           SDValue ThisVal) const;
     282             : 
     283             :   bool mayBeEmittedAsTailCall(const CallInst *) const override;
     284             : 
     285             :   bool isEligibleForTailCallOptimization(
     286             :     SDValue Callee, CallingConv::ID CalleeCC, bool isVarArg,
     287             :     const SmallVectorImpl<ISD::OutputArg> &Outs,
     288             :     const SmallVectorImpl<SDValue> &OutVals,
     289             :     const SmallVectorImpl<ISD::InputArg> &Ins, SelectionDAG &DAG) const;
     290             : 
     291             :   SDValue LowerCall(CallLoweringInfo &CLI,
     292             :                     SmallVectorImpl<SDValue> &InVals) const override;
     293             : 
     294             :   unsigned getRegisterByName(const char* RegName, EVT VT,
     295             :                              SelectionDAG &DAG) const override;
     296             : 
     297             :   MachineBasicBlock *splitKillBlock(MachineInstr &MI,
     298             :                                     MachineBasicBlock *BB) const;
     299             : 
     300             :   MachineBasicBlock *
     301             :   EmitInstrWithCustomInserter(MachineInstr &MI,
     302             :                               MachineBasicBlock *BB) const override;
     303             : 
     304             :   bool hasBitPreservingFPLogic(EVT VT) const override;
     305             :   bool enableAggressiveFMAFusion(EVT VT) const override;
     306             :   EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
     307             :                          EVT VT) const override;
     308             :   MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override;
     309             :   bool isFMAFasterThanFMulAndFAdd(EVT VT) const override;
     310             :   SDValue splitUnaryVectorOp(SDValue Op, SelectionDAG &DAG) const;
     311             :   SDValue splitBinaryVectorOp(SDValue Op, SelectionDAG &DAG) const;
     312             :   SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
     313             : 
     314             :   void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
     315             :                           SelectionDAG &DAG) const override;
     316             : 
     317             :   SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
     318             :   SDNode *PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const override;
     319             :   void AdjustInstrPostInstrSelection(MachineInstr &MI,
     320             :                                      SDNode *Node) const override;
     321             : 
     322             :   SDNode *legalizeTargetIndependentNode(SDNode *Node, SelectionDAG &DAG) const;
     323             : 
     324             :   MachineSDNode *wrapAddr64Rsrc(SelectionDAG &DAG, const SDLoc &DL,
     325             :                                 SDValue Ptr) const;
     326             :   MachineSDNode *buildRSRC(SelectionDAG &DAG, const SDLoc &DL, SDValue Ptr,
     327             :                            uint32_t RsrcDword1, uint64_t RsrcDword2And3) const;
     328             :   std::pair<unsigned, const TargetRegisterClass *>
     329             :   getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
     330             :                                StringRef Constraint, MVT VT) const override;
     331             :   ConstraintType getConstraintType(StringRef Constraint) const override;
     332             :   SDValue copyToM0(SelectionDAG &DAG, SDValue Chain, const SDLoc &DL,
     333             :                    SDValue V) const;
     334             : 
     335             :   void finalizeLowering(MachineFunction &MF) const override;
     336             : 
     337             :   void computeKnownBitsForFrameIndex(const SDValue Op,
     338             :                                      KnownBits &Known,
     339             :                                      const APInt &DemandedElts,
     340             :                                      const SelectionDAG &DAG,
     341             :                                      unsigned Depth = 0) const override;
     342             : 
     343             :   bool isSDNodeSourceOfDivergence(const SDNode *N,
     344             :     FunctionLoweringInfo *FLI, LegacyDivergenceAnalysis *DA) const override;
     345             : 
     346             :   bool isCanonicalized(SelectionDAG &DAG, SDValue Op,
     347             :                        unsigned MaxDepth = 5) const;
     348             :   bool denormalsEnabledForType(EVT VT) const;
     349             : };
     350             : 
     351             : } // End namespace llvm
     352             : 
     353             : #endif

Generated by: LCOV version 1.13