NVPTX.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. //===-- NVPTX.h - Top-level interface for NVPTX representation --*- C++ -*-===//
  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 contains the entry points for global functions defined in
  10. // the LLVM NVPTX back-end.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_LIB_TARGET_NVPTX_NVPTX_H
  14. #define LLVM_LIB_TARGET_NVPTX_NVPTX_H
  15. #include "llvm/IR/PassManager.h"
  16. #include "llvm/Pass.h"
  17. #include "llvm/Support/CodeGen.h"
  18. namespace llvm {
  19. class NVPTXTargetMachine;
  20. class FunctionPass;
  21. class MachineFunctionPass;
  22. namespace NVPTXCC {
  23. enum CondCodes {
  24. EQ,
  25. NE,
  26. LT,
  27. LE,
  28. GT,
  29. GE
  30. };
  31. }
  32. FunctionPass *createNVPTXISelDag(NVPTXTargetMachine &TM,
  33. llvm::CodeGenOpt::Level OptLevel);
  34. ModulePass *createNVPTXAssignValidGlobalNamesPass();
  35. ModulePass *createGenericToNVVMPass();
  36. FunctionPass *createNVVMIntrRangePass(unsigned int SmVersion);
  37. FunctionPass *createNVVMReflectPass(unsigned int SmVersion);
  38. MachineFunctionPass *createNVPTXPrologEpilogPass();
  39. MachineFunctionPass *createNVPTXReplaceImageHandlesPass();
  40. FunctionPass *createNVPTXImageOptimizerPass();
  41. FunctionPass *createNVPTXLowerArgsPass(const NVPTXTargetMachine *TM);
  42. FunctionPass *createNVPTXLowerAllocaPass();
  43. MachineFunctionPass *createNVPTXPeephole();
  44. MachineFunctionPass *createNVPTXProxyRegErasurePass();
  45. struct NVVMIntrRangePass : PassInfoMixin<NVVMIntrRangePass> {
  46. NVVMIntrRangePass();
  47. NVVMIntrRangePass(unsigned SmVersion) : SmVersion(SmVersion) {}
  48. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
  49. private:
  50. unsigned SmVersion;
  51. };
  52. struct NVVMReflectPass : PassInfoMixin<NVVMReflectPass> {
  53. NVVMReflectPass();
  54. NVVMReflectPass(unsigned SmVersion) : SmVersion(SmVersion) {}
  55. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
  56. private:
  57. unsigned SmVersion;
  58. };
  59. namespace NVPTX {
  60. enum DrvInterface {
  61. NVCL,
  62. CUDA
  63. };
  64. // A field inside TSFlags needs a shift and a mask. The usage is
  65. // always as follows :
  66. // ((TSFlags & fieldMask) >> fieldShift)
  67. // The enum keeps the mask, the shift, and all valid values of the
  68. // field in one place.
  69. enum VecInstType {
  70. VecInstTypeShift = 0,
  71. VecInstTypeMask = 0xF,
  72. VecNOP = 0,
  73. VecLoad = 1,
  74. VecStore = 2,
  75. VecBuild = 3,
  76. VecShuffle = 4,
  77. VecExtract = 5,
  78. VecInsert = 6,
  79. VecDest = 7,
  80. VecOther = 15
  81. };
  82. enum SimpleMove {
  83. SimpleMoveMask = 0x10,
  84. SimpleMoveShift = 4
  85. };
  86. enum LoadStore {
  87. isLoadMask = 0x20,
  88. isLoadShift = 5,
  89. isStoreMask = 0x40,
  90. isStoreShift = 6
  91. };
  92. namespace PTXLdStInstCode {
  93. enum AddressSpace {
  94. GENERIC = 0,
  95. GLOBAL = 1,
  96. CONSTANT = 2,
  97. SHARED = 3,
  98. PARAM = 4,
  99. LOCAL = 5
  100. };
  101. enum FromType {
  102. Unsigned = 0,
  103. Signed,
  104. Float,
  105. Untyped
  106. };
  107. enum VecType {
  108. Scalar = 1,
  109. V2 = 2,
  110. V4 = 4
  111. };
  112. }
  113. /// PTXCvtMode - Conversion code enumeration
  114. namespace PTXCvtMode {
  115. enum CvtMode {
  116. NONE = 0,
  117. RNI,
  118. RZI,
  119. RMI,
  120. RPI,
  121. RN,
  122. RZ,
  123. RM,
  124. RP,
  125. RNA,
  126. BASE_MASK = 0x0F,
  127. FTZ_FLAG = 0x10,
  128. SAT_FLAG = 0x20,
  129. RELU_FLAG = 0x40
  130. };
  131. }
  132. /// PTXCmpMode - Comparison mode enumeration
  133. namespace PTXCmpMode {
  134. enum CmpMode {
  135. EQ = 0,
  136. NE,
  137. LT,
  138. LE,
  139. GT,
  140. GE,
  141. LO,
  142. LS,
  143. HI,
  144. HS,
  145. EQU,
  146. NEU,
  147. LTU,
  148. LEU,
  149. GTU,
  150. GEU,
  151. NUM,
  152. // NAN is a MACRO
  153. NotANumber,
  154. BASE_MASK = 0xFF,
  155. FTZ_FLAG = 0x100
  156. };
  157. }
  158. }
  159. } // end namespace llvm;
  160. // Defines symbolic names for NVPTX registers. This defines a mapping from
  161. // register name to register number.
  162. #define GET_REGINFO_ENUM
  163. #include "NVPTXGenRegisterInfo.inc"
  164. // Defines symbolic names for the NVPTX instructions.
  165. #define GET_INSTRINFO_ENUM
  166. #include "NVPTXGenInstrInfo.inc"
  167. #endif