1*9880d681SAndroid Build Coastguard Worker //===-- NVPTXISelDAGToDAG.h - A dag to dag inst selector for NVPTX --------===// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker // 10*9880d681SAndroid Build Coastguard Worker // This file defines an instruction selector for the NVPTX target. 11*9880d681SAndroid Build Coastguard Worker // 12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXISELDAGTODAG_H 15*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_NVPTX_NVPTXISELDAGTODAG_H 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Worker #include "NVPTX.h" 18*9880d681SAndroid Build Coastguard Worker #include "NVPTXISelLowering.h" 19*9880d681SAndroid Build Coastguard Worker #include "NVPTXRegisterInfo.h" 20*9880d681SAndroid Build Coastguard Worker #include "NVPTXTargetMachine.h" 21*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/SelectionDAGISel.h" 22*9880d681SAndroid Build Coastguard Worker #include "llvm/IR/Intrinsics.h" 23*9880d681SAndroid Build Coastguard Worker #include "llvm/Support/Compiler.h" 24*9880d681SAndroid Build Coastguard Worker 25*9880d681SAndroid Build Coastguard Worker namespace llvm { 26*9880d681SAndroid Build Coastguard Worker 27*9880d681SAndroid Build Coastguard Worker class LLVM_LIBRARY_VISIBILITY NVPTXDAGToDAGISel : public SelectionDAGISel { 28*9880d681SAndroid Build Coastguard Worker const NVPTXTargetMachine &TM; 29*9880d681SAndroid Build Coastguard Worker 30*9880d681SAndroid Build Coastguard Worker // If true, generate mul.wide from sext and mul 31*9880d681SAndroid Build Coastguard Worker bool doMulWide; 32*9880d681SAndroid Build Coastguard Worker 33*9880d681SAndroid Build Coastguard Worker int getDivF32Level() const; 34*9880d681SAndroid Build Coastguard Worker bool usePrecSqrtF32() const; 35*9880d681SAndroid Build Coastguard Worker bool useF32FTZ() const; 36*9880d681SAndroid Build Coastguard Worker bool allowFMA() const; 37*9880d681SAndroid Build Coastguard Worker 38*9880d681SAndroid Build Coastguard Worker public: 39*9880d681SAndroid Build Coastguard Worker explicit NVPTXDAGToDAGISel(NVPTXTargetMachine &tm, 40*9880d681SAndroid Build Coastguard Worker CodeGenOpt::Level OptLevel); 41*9880d681SAndroid Build Coastguard Worker 42*9880d681SAndroid Build Coastguard Worker // Pass Name getPassName()43*9880d681SAndroid Build Coastguard Worker const char *getPassName() const override { 44*9880d681SAndroid Build Coastguard Worker return "NVPTX DAG->DAG Pattern Instruction Selection"; 45*9880d681SAndroid Build Coastguard Worker } 46*9880d681SAndroid Build Coastguard Worker bool runOnMachineFunction(MachineFunction &MF) override; 47*9880d681SAndroid Build Coastguard Worker const NVPTXSubtarget *Subtarget; 48*9880d681SAndroid Build Coastguard Worker 49*9880d681SAndroid Build Coastguard Worker bool SelectInlineAsmMemoryOperand(const SDValue &Op, 50*9880d681SAndroid Build Coastguard Worker unsigned ConstraintID, 51*9880d681SAndroid Build Coastguard Worker std::vector<SDValue> &OutOps) override; 52*9880d681SAndroid Build Coastguard Worker private: 53*9880d681SAndroid Build Coastguard Worker // Include the pieces autogenerated from the target description. 54*9880d681SAndroid Build Coastguard Worker #include "NVPTXGenDAGISel.inc" 55*9880d681SAndroid Build Coastguard Worker 56*9880d681SAndroid Build Coastguard Worker void Select(SDNode *N) override; 57*9880d681SAndroid Build Coastguard Worker bool tryIntrinsicNoChain(SDNode *N); 58*9880d681SAndroid Build Coastguard Worker bool tryIntrinsicChain(SDNode *N); 59*9880d681SAndroid Build Coastguard Worker void SelectTexSurfHandle(SDNode *N); 60*9880d681SAndroid Build Coastguard Worker bool tryLoad(SDNode *N); 61*9880d681SAndroid Build Coastguard Worker bool tryLoadVector(SDNode *N); 62*9880d681SAndroid Build Coastguard Worker bool tryLDGLDU(SDNode *N); 63*9880d681SAndroid Build Coastguard Worker bool tryStore(SDNode *N); 64*9880d681SAndroid Build Coastguard Worker bool tryStoreVector(SDNode *N); 65*9880d681SAndroid Build Coastguard Worker bool tryLoadParam(SDNode *N); 66*9880d681SAndroid Build Coastguard Worker bool tryStoreRetval(SDNode *N); 67*9880d681SAndroid Build Coastguard Worker bool tryStoreParam(SDNode *N); 68*9880d681SAndroid Build Coastguard Worker void SelectAddrSpaceCast(SDNode *N); 69*9880d681SAndroid Build Coastguard Worker bool tryTextureIntrinsic(SDNode *N); 70*9880d681SAndroid Build Coastguard Worker bool trySurfaceIntrinsic(SDNode *N); 71*9880d681SAndroid Build Coastguard Worker bool tryBFE(SDNode *N); 72*9880d681SAndroid Build Coastguard Worker getI32Imm(unsigned Imm,const SDLoc & DL)73*9880d681SAndroid Build Coastguard Worker inline SDValue getI32Imm(unsigned Imm, const SDLoc &DL) { 74*9880d681SAndroid Build Coastguard Worker return CurDAG->getTargetConstant(Imm, DL, MVT::i32); 75*9880d681SAndroid Build Coastguard Worker } 76*9880d681SAndroid Build Coastguard Worker 77*9880d681SAndroid Build Coastguard Worker // Match direct address complex pattern. 78*9880d681SAndroid Build Coastguard Worker bool SelectDirectAddr(SDValue N, SDValue &Address); 79*9880d681SAndroid Build Coastguard Worker 80*9880d681SAndroid Build Coastguard Worker bool SelectADDRri_imp(SDNode *OpNode, SDValue Addr, SDValue &Base, 81*9880d681SAndroid Build Coastguard Worker SDValue &Offset, MVT mvt); 82*9880d681SAndroid Build Coastguard Worker bool SelectADDRri(SDNode *OpNode, SDValue Addr, SDValue &Base, 83*9880d681SAndroid Build Coastguard Worker SDValue &Offset); 84*9880d681SAndroid Build Coastguard Worker bool SelectADDRri64(SDNode *OpNode, SDValue Addr, SDValue &Base, 85*9880d681SAndroid Build Coastguard Worker SDValue &Offset); 86*9880d681SAndroid Build Coastguard Worker 87*9880d681SAndroid Build Coastguard Worker bool SelectADDRsi_imp(SDNode *OpNode, SDValue Addr, SDValue &Base, 88*9880d681SAndroid Build Coastguard Worker SDValue &Offset, MVT mvt); 89*9880d681SAndroid Build Coastguard Worker bool SelectADDRsi(SDNode *OpNode, SDValue Addr, SDValue &Base, 90*9880d681SAndroid Build Coastguard Worker SDValue &Offset); 91*9880d681SAndroid Build Coastguard Worker bool SelectADDRsi64(SDNode *OpNode, SDValue Addr, SDValue &Base, 92*9880d681SAndroid Build Coastguard Worker SDValue &Offset); 93*9880d681SAndroid Build Coastguard Worker 94*9880d681SAndroid Build Coastguard Worker bool ChkMemSDNodeAddressSpace(SDNode *N, unsigned int spN) const; 95*9880d681SAndroid Build Coastguard Worker 96*9880d681SAndroid Build Coastguard Worker static unsigned GetConvertOpcode(MVT DestTy, MVT SrcTy, bool IsSigned); 97*9880d681SAndroid Build Coastguard Worker }; 98*9880d681SAndroid Build Coastguard Worker } // end namespace llvm 99*9880d681SAndroid Build Coastguard Worker 100*9880d681SAndroid Build Coastguard Worker #endif 101