X86TargetParser.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- X86TargetParser - Parser for X86 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 X86 hardware features.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_SUPPORT_X86TARGETPARSER_H
  18. #define LLVM_SUPPORT_X86TARGETPARSER_H
  19. #include "llvm/ADT/ArrayRef.h"
  20. #include "llvm/ADT/StringMap.h"
  21. namespace llvm {
  22. template <typename T> class SmallVectorImpl;
  23. class StringRef;
  24. namespace X86 {
  25. // This should be kept in sync with libcc/compiler-rt as its included by clang
  26. // as a proxy for what's in libgcc/compiler-rt.
  27. enum ProcessorVendors : unsigned {
  28. VENDOR_DUMMY,
  29. #define X86_VENDOR(ENUM, STRING) \
  30. ENUM,
  31. #include "llvm/Support/X86TargetParser.def"
  32. VENDOR_OTHER
  33. };
  34. // This should be kept in sync with libcc/compiler-rt as its included by clang
  35. // as a proxy for what's in libgcc/compiler-rt.
  36. enum ProcessorTypes : unsigned {
  37. CPU_TYPE_DUMMY,
  38. #define X86_CPU_TYPE(ENUM, STRING) \
  39. ENUM,
  40. #include "llvm/Support/X86TargetParser.def"
  41. CPU_TYPE_MAX
  42. };
  43. // This should be kept in sync with libcc/compiler-rt as its included by clang
  44. // as a proxy for what's in libgcc/compiler-rt.
  45. enum ProcessorSubtypes : unsigned {
  46. CPU_SUBTYPE_DUMMY,
  47. #define X86_CPU_SUBTYPE(ENUM, STRING) \
  48. ENUM,
  49. #include "llvm/Support/X86TargetParser.def"
  50. CPU_SUBTYPE_MAX
  51. };
  52. // This should be kept in sync with libcc/compiler-rt as it should be used
  53. // by clang as a proxy for what's in libgcc/compiler-rt.
  54. enum ProcessorFeatures {
  55. #define X86_FEATURE(ENUM, STRING) FEATURE_##ENUM,
  56. #include "llvm/Support/X86TargetParser.def"
  57. CPU_FEATURE_MAX
  58. };
  59. enum CPUKind {
  60. CK_None,
  61. CK_i386,
  62. CK_i486,
  63. CK_WinChipC6,
  64. CK_WinChip2,
  65. CK_C3,
  66. CK_i586,
  67. CK_Pentium,
  68. CK_PentiumMMX,
  69. CK_PentiumPro,
  70. CK_i686,
  71. CK_Pentium2,
  72. CK_Pentium3,
  73. CK_PentiumM,
  74. CK_C3_2,
  75. CK_Yonah,
  76. CK_Pentium4,
  77. CK_Prescott,
  78. CK_Nocona,
  79. CK_Core2,
  80. CK_Penryn,
  81. CK_Bonnell,
  82. CK_Silvermont,
  83. CK_Goldmont,
  84. CK_GoldmontPlus,
  85. CK_Tremont,
  86. CK_Nehalem,
  87. CK_Westmere,
  88. CK_SandyBridge,
  89. CK_IvyBridge,
  90. CK_Haswell,
  91. CK_Broadwell,
  92. CK_SkylakeClient,
  93. CK_SkylakeServer,
  94. CK_Cascadelake,
  95. CK_Cooperlake,
  96. CK_Cannonlake,
  97. CK_IcelakeClient,
  98. CK_Rocketlake,
  99. CK_IcelakeServer,
  100. CK_Tigerlake,
  101. CK_SapphireRapids,
  102. CK_Alderlake,
  103. CK_KNL,
  104. CK_KNM,
  105. CK_Lakemont,
  106. CK_K6,
  107. CK_K6_2,
  108. CK_K6_3,
  109. CK_Athlon,
  110. CK_AthlonXP,
  111. CK_K8,
  112. CK_K8SSE3,
  113. CK_AMDFAM10,
  114. CK_BTVER1,
  115. CK_BTVER2,
  116. CK_BDVER1,
  117. CK_BDVER2,
  118. CK_BDVER3,
  119. CK_BDVER4,
  120. CK_ZNVER1,
  121. CK_ZNVER2,
  122. CK_ZNVER3,
  123. CK_x86_64,
  124. CK_x86_64_v2,
  125. CK_x86_64_v3,
  126. CK_x86_64_v4,
  127. CK_Geode,
  128. };
  129. /// Parse \p CPU string into a CPUKind. Will only accept 64-bit capable CPUs if
  130. /// \p Only64Bit is true.
  131. CPUKind parseArchX86(StringRef CPU, bool Only64Bit = false);
  132. CPUKind parseTuneCPU(StringRef CPU, bool Only64Bit = false);
  133. /// Provide a list of valid CPU names. If \p Only64Bit is true, the list will
  134. /// only contain 64-bit capable CPUs.
  135. void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values,
  136. bool Only64Bit = false);
  137. /// Provide a list of valid -mtune names.
  138. void fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values,
  139. bool Only64Bit = false);
  140. /// Get the key feature prioritizing target multiversioning.
  141. ProcessorFeatures getKeyFeature(CPUKind Kind);
  142. /// Fill in the features that \p CPU supports into \p Features.
  143. void getFeaturesForCPU(StringRef CPU, SmallVectorImpl<StringRef> &Features);
  144. /// Set or clear entries in \p Features that are implied to be enabled/disabled
  145. /// by the provided \p Feature.
  146. void updateImpliedFeatures(StringRef Feature, bool Enabled,
  147. StringMap<bool> &Features);
  148. uint64_t getCpuSupportsMask(ArrayRef<StringRef> FeatureStrs);
  149. unsigned getFeaturePriority(ProcessorFeatures Feat);
  150. } // namespace X86
  151. } // namespace llvm
  152. #endif
  153. #ifdef __GNUC__
  154. #pragma GCC diagnostic pop
  155. #endif