1 //===-- NVPTXISelDAGToDAG.h - A dag to dag inst selector for NVPTX --------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines an instruction selector for the NVPTX target.
12 //===----------------------------------------------------------------------===//
15 #include "NVPTXISelLowering.h"
16 #include "NVPTXRegisterInfo.h"
17 #include "NVPTXTargetMachine.h"
18 #include "llvm/CodeGen/SelectionDAGISel.h"
19 #include "llvm/IR/Intrinsics.h"
20 #include "llvm/Support/Compiler.h"
25 class LLVM_LIBRARY_VISIBILITY NVPTXDAGToDAGISel : public SelectionDAGISel {
27 // If true, generate mul.wide from sext and mul
30 int getDivF32Level() const;
31 bool usePrecSqrtF32() const;
32 bool useF32FTZ() const;
33 bool allowFMA() const;
36 explicit NVPTXDAGToDAGISel(NVPTXTargetMachine &tm,
37 CodeGenOpt::Level OptLevel);
40 const char *getPassName() const override {
41 return "NVPTX DAG->DAG Pattern Instruction Selection";
44 const NVPTXSubtarget &Subtarget;
46 bool SelectInlineAsmMemoryOperand(const SDValue &Op,
48 std::vector<SDValue> &OutOps) override;
50 // Include the pieces autogenerated from the target description.
51 #include "NVPTXGenDAGISel.inc"
53 SDNode *Select(SDNode *N) override;
54 SDNode *SelectIntrinsicNoChain(SDNode *N);
55 SDNode *SelectIntrinsicChain(SDNode *N);
56 SDNode *SelectTexSurfHandle(SDNode *N);
57 SDNode *SelectLoad(SDNode *N);
58 SDNode *SelectLoadVector(SDNode *N);
59 SDNode *SelectLDGLDU(SDNode *N);
60 SDNode *SelectStore(SDNode *N);
61 SDNode *SelectStoreVector(SDNode *N);
62 SDNode *SelectLoadParam(SDNode *N);
63 SDNode *SelectStoreRetval(SDNode *N);
64 SDNode *SelectStoreParam(SDNode *N);
65 SDNode *SelectAddrSpaceCast(SDNode *N);
66 SDNode *SelectTextureIntrinsic(SDNode *N);
67 SDNode *SelectSurfaceIntrinsic(SDNode *N);
68 SDNode *SelectBFE(SDNode *N);
70 inline SDValue getI32Imm(unsigned Imm) {
71 return CurDAG->getTargetConstant(Imm, MVT::i32);
74 // Match direct address complex pattern.
75 bool SelectDirectAddr(SDValue N, SDValue &Address);
77 bool SelectADDRri_imp(SDNode *OpNode, SDValue Addr, SDValue &Base,
78 SDValue &Offset, MVT mvt);
79 bool SelectADDRri(SDNode *OpNode, SDValue Addr, SDValue &Base,
81 bool SelectADDRri64(SDNode *OpNode, SDValue Addr, SDValue &Base,
84 bool SelectADDRsi_imp(SDNode *OpNode, SDValue Addr, SDValue &Base,
85 SDValue &Offset, MVT mvt);
86 bool SelectADDRsi(SDNode *OpNode, SDValue Addr, SDValue &Base,
88 bool SelectADDRsi64(SDNode *OpNode, SDValue Addr, SDValue &Base,
91 bool ChkMemSDNodeAddressSpace(SDNode *N, unsigned int spN) const;