LoongArchTargetParser.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //==-- LoongArch64TargetParser - Parser for LoongArch64 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 LoongArch hardware features
  15. // such as CPU/ARCH and extension names.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_TARGETPARSER_LOONGARCHTARGETPARSER_H
  19. #define LLVM_TARGETPARSER_LOONGARCHTARGETPARSER_H
  20. #include "llvm/TargetParser/Triple.h"
  21. #include <vector>
  22. namespace llvm {
  23. class StringRef;
  24. namespace LoongArch {
  25. enum FeatureKind : uint32_t {
  26. FK_INVALID = 0,
  27. FK_NONE = 1,
  28. // 64-bit ISA is available.
  29. FK_64BIT = 1 << 1,
  30. // Single-precision floating-point instructions are available.
  31. FK_FP32 = 1 << 2,
  32. // Double-precision floating-point instructions are available.
  33. FK_FP64 = 1 << 3,
  34. // Loongson SIMD Extension is available.
  35. FK_LSX = 1 << 4,
  36. // Loongson Advanced SIMD Extension is available.
  37. FK_LASX = 1 << 5,
  38. // Loongson Binary Translation Extension is available.
  39. FK_LBT = 1 << 6,
  40. // Loongson Virtualization Extension is available.
  41. FK_LVZ = 1 << 7,
  42. };
  43. struct FeatureInfo {
  44. StringRef Name;
  45. FeatureKind Kind;
  46. };
  47. enum class ArchKind {
  48. #define LOONGARCH_ARCH(NAME, KIND, FEATURES) KIND,
  49. #include "LoongArchTargetParser.def"
  50. };
  51. struct ArchInfo {
  52. StringRef Name;
  53. ArchKind Kind;
  54. uint32_t Features;
  55. };
  56. ArchKind parseArch(StringRef Arch);
  57. bool getArchFeatures(StringRef Arch, std::vector<StringRef> &Features);
  58. } // namespace LoongArch
  59. } // namespace llvm
  60. #endif // LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
  61. #ifdef __GNUC__
  62. #pragma GCC diagnostic pop
  63. #endif