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. static char ID;
  35. NVPTXDAGToDAGISel() = delete;
  36. explicit NVPTXDAGToDAGISel(NVPTXTargetMachine &tm,
  37. CodeGenOpt::Level OptLevel);
  38. bool runOnMachineFunction(MachineFunction &MF) override;
  39. const NVPTXSubtarget *Subtarget = nullptr;
  40. bool SelectInlineAsmMemoryOperand(const SDValue &Op,
  41. unsigned ConstraintID,
  42. std::vector<SDValue> &OutOps) override;
  43. private:
  44. // Include the pieces autogenerated from the target description.
  45. #include "NVPTXGenDAGISel.inc"
  46. void Select(SDNode *N) override;
  47. bool tryIntrinsicNoChain(SDNode *N);
  48. bool tryIntrinsicChain(SDNode *N);
  49. void SelectTexSurfHandle(SDNode *N);
  50. bool tryLoad(SDNode *N);
  51. bool tryLoadVector(SDNode *N);
  52. bool tryLDGLDU(SDNode *N);
  53. bool tryStore(SDNode *N);
  54. bool tryStoreVector(SDNode *N);
  55. bool tryLoadParam(SDNode *N);
  56. bool tryStoreRetval(SDNode *N);
  57. bool tryStoreParam(SDNode *N);
  58. void SelectAddrSpaceCast(SDNode *N);
  59. bool tryTextureIntrinsic(SDNode *N);
  60. bool trySurfaceIntrinsic(SDNode *N);
  61. bool tryBFE(SDNode *N);
  62. bool tryConstantFP16(SDNode *N);
  63. bool SelectSETP_F16X2(SDNode *N);
  64. bool tryEXTRACT_VECTOR_ELEMENT(SDNode *N);
  65. inline SDValue getI32Imm(unsigned Imm, const SDLoc &DL) {
  66. return CurDAG->getTargetConstant(Imm, DL, MVT::i32);
  67. }
  68. // Match direct address complex pattern.
  69. bool SelectDirectAddr(SDValue N, SDValue &Address);
  70. bool SelectADDRri_imp(SDNode *OpNode, SDValue Addr, SDValue &Base,
  71. SDValue &Offset, MVT mvt);
  72. bool SelectADDRri(SDNode *OpNode, SDValue Addr, SDValue &Base,
  73. SDValue &Offset);
  74. bool SelectADDRri64(SDNode *OpNode, SDValue Addr, SDValue &Base,
  75. SDValue &Offset);
  76. bool SelectADDRsi_imp(SDNode *OpNode, SDValue Addr, SDValue &Base,
  77. SDValue &Offset, MVT mvt);
  78. bool SelectADDRsi(SDNode *OpNode, SDValue Addr, SDValue &Base,
  79. SDValue &Offset);
  80. bool SelectADDRsi64(SDNode *OpNode, SDValue Addr, SDValue &Base,
  81. SDValue &Offset);
  82. bool ChkMemSDNodeAddressSpace(SDNode *N, unsigned int spN) const;
  83. static unsigned GetConvertOpcode(MVT DestTy, MVT SrcTy, bool IsSigned);
  84. };
  85. } // end namespace llvm
  86. #endif