TargetParser.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- TargetParser - Parser for target features ---------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file implements a target parser to recognise hardware features such as
  15. // FPU/CPU/ARCH names as well as specific support such as HDIV, etc.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_TARGETPARSER_TARGETPARSER_H
  19. #define LLVM_TARGETPARSER_TARGETPARSER_H
  20. #include "llvm/ADT/StringRef.h"
  21. #include <cstdint>
  22. // FIXME: vector is used because that's what clang uses for subtarget feature
  23. // lists, but SmallVector would probably be better
  24. #include <vector>
  25. namespace llvm {
  26. template <typename T> class SmallVectorImpl;
  27. class Triple;
  28. // Target specific information in their own namespaces.
  29. // (ARM/AArch64/X86 are declared in ARM/AArch64/X86TargetParser.h)
  30. // These should be generated from TableGen because the information is already
  31. // there, and there is where new information about targets will be added.
  32. // FIXME: To TableGen this we need to make some table generated files available
  33. // even if the back-end is not compiled with LLVM, plus we need to create a new
  34. // back-end to TableGen to create these clean tables.
  35. namespace AMDGPU {
  36. /// GPU kinds supported by the AMDGPU target.
  37. enum GPUKind : uint32_t {
  38. // Not specified processor.
  39. GK_NONE = 0,
  40. // R600-based processors.
  41. GK_R600 = 1,
  42. GK_R630 = 2,
  43. GK_RS880 = 3,
  44. GK_RV670 = 4,
  45. GK_RV710 = 5,
  46. GK_RV730 = 6,
  47. GK_RV770 = 7,
  48. GK_CEDAR = 8,
  49. GK_CYPRESS = 9,
  50. GK_JUNIPER = 10,
  51. GK_REDWOOD = 11,
  52. GK_SUMO = 12,
  53. GK_BARTS = 13,
  54. GK_CAICOS = 14,
  55. GK_CAYMAN = 15,
  56. GK_TURKS = 16,
  57. GK_R600_FIRST = GK_R600,
  58. GK_R600_LAST = GK_TURKS,
  59. // AMDGCN-based processors.
  60. GK_GFX600 = 32,
  61. GK_GFX601 = 33,
  62. GK_GFX602 = 34,
  63. GK_GFX700 = 40,
  64. GK_GFX701 = 41,
  65. GK_GFX702 = 42,
  66. GK_GFX703 = 43,
  67. GK_GFX704 = 44,
  68. GK_GFX705 = 45,
  69. GK_GFX801 = 50,
  70. GK_GFX802 = 51,
  71. GK_GFX803 = 52,
  72. GK_GFX805 = 53,
  73. GK_GFX810 = 54,
  74. GK_GFX900 = 60,
  75. GK_GFX902 = 61,
  76. GK_GFX904 = 62,
  77. GK_GFX906 = 63,
  78. GK_GFX908 = 64,
  79. GK_GFX909 = 65,
  80. GK_GFX90A = 66,
  81. GK_GFX90C = 67,
  82. GK_GFX940 = 68,
  83. GK_GFX1010 = 71,
  84. GK_GFX1011 = 72,
  85. GK_GFX1012 = 73,
  86. GK_GFX1013 = 74,
  87. GK_GFX1030 = 75,
  88. GK_GFX1031 = 76,
  89. GK_GFX1032 = 77,
  90. GK_GFX1033 = 78,
  91. GK_GFX1034 = 79,
  92. GK_GFX1035 = 80,
  93. GK_GFX1036 = 81,
  94. GK_GFX1100 = 90,
  95. GK_GFX1101 = 91,
  96. GK_GFX1102 = 92,
  97. GK_GFX1103 = 93,
  98. GK_AMDGCN_FIRST = GK_GFX600,
  99. GK_AMDGCN_LAST = GK_GFX1103,
  100. };
  101. /// Instruction set architecture version.
  102. struct IsaVersion {
  103. unsigned Major;
  104. unsigned Minor;
  105. unsigned Stepping;
  106. };
  107. // This isn't comprehensive for now, just things that are needed from the
  108. // frontend driver.
  109. enum ArchFeatureKind : uint32_t {
  110. FEATURE_NONE = 0,
  111. // These features only exist for r600, and are implied true for amdgcn.
  112. FEATURE_FMA = 1 << 1,
  113. FEATURE_LDEXP = 1 << 2,
  114. FEATURE_FP64 = 1 << 3,
  115. // Common features.
  116. FEATURE_FAST_FMA_F32 = 1 << 4,
  117. FEATURE_FAST_DENORMAL_F32 = 1 << 5,
  118. // Wavefront 32 is available.
  119. FEATURE_WAVE32 = 1 << 6,
  120. // Xnack is available.
  121. FEATURE_XNACK = 1 << 7,
  122. // Sram-ecc is available.
  123. FEATURE_SRAMECC = 1 << 8,
  124. };
  125. StringRef getArchNameAMDGCN(GPUKind AK);
  126. StringRef getArchNameR600(GPUKind AK);
  127. StringRef getCanonicalArchName(const Triple &T, StringRef Arch);
  128. GPUKind parseArchAMDGCN(StringRef CPU);
  129. GPUKind parseArchR600(StringRef CPU);
  130. unsigned getArchAttrAMDGCN(GPUKind AK);
  131. unsigned getArchAttrR600(GPUKind AK);
  132. void fillValidArchListAMDGCN(SmallVectorImpl<StringRef> &Values);
  133. void fillValidArchListR600(SmallVectorImpl<StringRef> &Values);
  134. IsaVersion getIsaVersion(StringRef GPU);
  135. } // namespace AMDGPU
  136. } // namespace llvm
  137. #endif
  138. #ifdef __GNUC__
  139. #pragma GCC diagnostic pop
  140. #endif