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"
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;
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,
50 unsigned ConstraintID,
51 std::vector<SDValue> &OutOps) override;
53 // Include the pieces autogenerated from the target description.
54 #include "NVPTXGenDAGISel.inc"
56 void Select(SDNode *N) override;
57 bool tryIntrinsicNoChain(SDNode *N);
58 bool tryIntrinsicChain(SDNode *N);
59 void SelectTexSurfHandle(SDNode *N);
60 bool tryLoad(SDNode *N);
61 bool tryLoadVector(SDNode *N);
62 bool tryLDGLDU(SDNode *N);
63 bool tryStore(SDNode *N);
64 bool tryStoreVector(SDNode *N);
65 bool tryLoadParam(SDNode *N);
66 bool tryStoreRetval(SDNode *N);
67 bool tryStoreParam(SDNode *N);
68 void SelectAddrSpaceCast(SDNode *N);
69 bool tryTextureIntrinsic(SDNode *N);
70 bool trySurfaceIntrinsic(SDNode *N);
71 bool tryBFE(SDNode *N);
73 inline SDValue getI32Imm(unsigned Imm, const SDLoc &DL) {
74 return CurDAG->getTargetConstant(Imm, DL, 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;
96 static unsigned GetConvertOpcode(MVT DestTy, MVT SrcTy, bool IsSigned);
98 } // end namespace llvm