NVPTXISelDAGToDAG.h 3.5 KB

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