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 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXISELDAGTODAG_H
15 #define LLVM_LIB_TARGET_NVPTX_NVPTXISELDAGTODAG_H
18 #include "NVPTXISelLowering.h"
19 #include "NVPTXRegisterInfo.h"
20 #include "NVPTXTargetMachine.h"
21 #include "llvm/CodeGen/SelectionDAGISel.h"
22 #include "llvm/IR/Intrinsics.h"
23 #include "llvm/Support/Compiler.h"
28 class LLVM_LIBRARY_VISIBILITY NVPTXDAGToDAGISel : public SelectionDAGISel {
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;
39 explicit NVPTXDAGToDAGISel(NVPTXTargetMachine &tm,
40 CodeGenOpt::Level OptLevel);
43 const char *getPassName() const override {
44 return "NVPTX DAG->DAG Pattern Instruction Selection";
46 bool runOnMachineFunction(MachineFunction &MF) override;
47 const NVPTXSubtarget *Subtarget;
49 bool SelectInlineAsmMemoryOperand(const SDValue &Op,
51 std::vector<SDValue> &OutOps) override;
53 // Include the pieces autogenerated from the target description.
54 #include "NVPTXGenDAGISel.inc"
56 SDNode *Select(SDNode *N) override;
57 SDNode *SelectIntrinsicNoChain(SDNode *N);
58 SDNode *SelectIntrinsicChain(SDNode *N);
59 SDNode *SelectTexSurfHandle(SDNode *N);
60 SDNode *SelectLoad(SDNode *N);
61 SDNode *SelectLoadVector(SDNode *N);
62 SDNode *SelectLDGLDU(SDNode *N);
63 SDNode *SelectStore(SDNode *N);
64 SDNode *SelectStoreVector(SDNode *N);
65 SDNode *SelectLoadParam(SDNode *N);
66 SDNode *SelectStoreRetval(SDNode *N);
67 SDNode *SelectStoreParam(SDNode *N);
68 SDNode *SelectAddrSpaceCast(SDNode *N);
69 SDNode *SelectTextureIntrinsic(SDNode *N);
70 SDNode *SelectSurfaceIntrinsic(SDNode *N);
71 SDNode *SelectBFE(SDNode *N);
73 inline SDValue getI32Imm(unsigned Imm) {
74 return CurDAG->getTargetConstant(Imm, MVT::i32);
77 // Match direct address complex pattern.
78 bool SelectDirectAddr(SDValue N, SDValue &Address);
80 bool SelectADDRri_imp(SDNode *OpNode, SDValue Addr, SDValue &Base,
81 SDValue &Offset, MVT mvt);
82 bool SelectADDRri(SDNode *OpNode, SDValue Addr, SDValue &Base,
84 bool SelectADDRri64(SDNode *OpNode, SDValue Addr, SDValue &Base,
87 bool SelectADDRsi_imp(SDNode *OpNode, SDValue Addr, SDValue &Base,
88 SDValue &Offset, MVT mvt);
89 bool SelectADDRsi(SDNode *OpNode, SDValue Addr, SDValue &Base,
91 bool SelectADDRsi64(SDNode *OpNode, SDValue Addr, SDValue &Base,
94 bool ChkMemSDNodeAddressSpace(SDNode *N, unsigned int spN) const;