1 //===-- NVPTXISelDAGToDAG.h - A dag to dag inst selector for NVPTX --------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines an instruction selector for the NVPTX target.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXISELDAGTODAG_H
14 #define LLVM_LIB_TARGET_NVPTX_NVPTXISELDAGTODAG_H
17 #include "NVPTXISelLowering.h"
18 #include "NVPTXRegisterInfo.h"
19 #include "NVPTXTargetMachine.h"
20 #include "MCTargetDesc/NVPTXBaseInfo.h"
21 #include "llvm/CodeGen/SelectionDAGISel.h"
22 #include "llvm/IR/Intrinsics.h"
23 #include "llvm/Support/Compiler.h"
27 class LLVM_LIBRARY_VISIBILITY NVPTXDAGToDAGISel
: public SelectionDAGISel
{
28 const NVPTXTargetMachine
&TM
;
30 // If true, generate mul.wide from sext and mul
33 int getDivF32Level() const;
34 bool usePrecSqrtF32() const;
35 bool useF32FTZ() const;
36 bool allowFMA() const;
37 bool allowUnsafeFPMath() const;
38 bool useShortPointers() const;
41 explicit NVPTXDAGToDAGISel(NVPTXTargetMachine
&tm
,
42 CodeGenOpt::Level OptLevel
);
45 StringRef
getPassName() const override
{
46 return "NVPTX DAG->DAG Pattern Instruction Selection";
48 bool runOnMachineFunction(MachineFunction
&MF
) override
;
49 const NVPTXSubtarget
*Subtarget
;
51 bool SelectInlineAsmMemoryOperand(const SDValue
&Op
,
52 unsigned ConstraintID
,
53 std::vector
<SDValue
> &OutOps
) override
;
55 // Include the pieces autogenerated from the target description.
56 #include "NVPTXGenDAGISel.inc"
58 void Select(SDNode
*N
) override
;
59 bool tryIntrinsicNoChain(SDNode
*N
);
60 bool tryIntrinsicChain(SDNode
*N
);
61 void SelectTexSurfHandle(SDNode
*N
);
62 bool tryLoad(SDNode
*N
);
63 bool tryLoadVector(SDNode
*N
);
64 bool tryLDGLDU(SDNode
*N
);
65 bool tryStore(SDNode
*N
);
66 bool tryStoreVector(SDNode
*N
);
67 bool tryLoadParam(SDNode
*N
);
68 bool tryStoreRetval(SDNode
*N
);
69 bool tryStoreParam(SDNode
*N
);
70 void SelectAddrSpaceCast(SDNode
*N
);
71 bool tryTextureIntrinsic(SDNode
*N
);
72 bool trySurfaceIntrinsic(SDNode
*N
);
73 bool tryBFE(SDNode
*N
);
74 bool tryConstantFP16(SDNode
*N
);
75 bool SelectSETP_F16X2(SDNode
*N
);
76 bool tryEXTRACT_VECTOR_ELEMENT(SDNode
*N
);
78 inline SDValue
getI32Imm(unsigned Imm
, const SDLoc
&DL
) {
79 return CurDAG
->getTargetConstant(Imm
, DL
, MVT::i32
);
82 // Match direct address complex pattern.
83 bool SelectDirectAddr(SDValue N
, SDValue
&Address
);
85 bool SelectADDRri_imp(SDNode
*OpNode
, SDValue Addr
, SDValue
&Base
,
86 SDValue
&Offset
, MVT mvt
);
87 bool SelectADDRri(SDNode
*OpNode
, SDValue Addr
, SDValue
&Base
,
89 bool SelectADDRri64(SDNode
*OpNode
, SDValue Addr
, SDValue
&Base
,
91 bool SelectADDRsi_imp(SDNode
*OpNode
, SDValue Addr
, SDValue
&Base
,
92 SDValue
&Offset
, MVT mvt
);
93 bool SelectADDRsi(SDNode
*OpNode
, SDValue Addr
, SDValue
&Base
,
95 bool SelectADDRsi64(SDNode
*OpNode
, SDValue Addr
, SDValue
&Base
,
98 bool ChkMemSDNodeAddressSpace(SDNode
*N
, unsigned int spN
) const;
100 static unsigned GetConvertOpcode(MVT DestTy
, MVT SrcTy
, bool IsSigned
);
102 } // end namespace llvm