0005-support-b-letter-in-march-string.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. From 49624b4167173ffbbf3bdf1b9cfa33d5efcd1f0b Mon Sep 17 00:00:00 2001
  2. From: "max.ma" <max.ma@starfivetech.com>
  3. Date: Fri, 15 Apr 2022 02:16:43 -0700
  4. Subject: [PATCH 5/6] support "b" letter in march string
  5. ---
  6. llvm/lib/Support/RISCVISAInfo.cpp | 8 +++++++-
  7. llvm/lib/Target/RISCV/RISCV.td | 11 +++++++++++
  8. llvm/lib/Target/RISCV/RISCVSubtarget.h | 2 ++
  9. 3 files changed, 20 insertions(+), 1 deletion(-)
  10. diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp
  11. index 20dd08f17311..edeceeaf4e82 100644
  12. --- a/llvm/lib/Support/RISCVISAInfo.cpp
  13. +++ b/llvm/lib/Support/RISCVISAInfo.cpp
  14. @@ -600,7 +600,13 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
  15. return createStringError(errc::invalid_argument,
  16. "unsupported standard user-level extension '%c'",
  17. C);
  18. - ISAInfo->addExtension(std::string(1, C), Major, Minor);
  19. + if (C == 'b') {
  20. + ISAInfo->addExtension("zba", Major, Minor);
  21. + ISAInfo->addExtension("zbb", Major, Minor);
  22. + ISAInfo->addExtension("zbc", Major, Minor);
  23. + ISAInfo->addExtension("zbs", Major, Minor);
  24. + } else
  25. + ISAInfo->addExtension(std::string(1, C), Major, Minor);
  26. // Consume full extension name and version, including any optional '_'
  27. // between this extension and the next
  28. diff --git a/llvm/lib/Target/RISCV/RISCV.td b/llvm/lib/Target/RISCV/RISCV.td
  29. index 2940fdf04192..e9b64bdafab8 100644
  30. --- a/llvm/lib/Target/RISCV/RISCV.td
  31. +++ b/llvm/lib/Target/RISCV/RISCV.td
  32. @@ -193,6 +193,17 @@ def HasStdExtZbbOrZbp
  33. "'Zbb' (Basic Bit-Manipulation) or "
  34. "'Zbp' (Permutation 'Zb' Instructions)">;
  35. +def FeatureStdExtB
  36. + : SubtargetFeature<"b", "HasStdExtB", "true",
  37. + "'B' (Bit Manipulation Instructions)",
  38. + [FeatureStdExtZba,
  39. + FeatureStdExtZbb,
  40. + FeatureStdExtZbc,
  41. + FeatureStdExtZbs]>;
  42. +def HasStdExtB : Predicate<"Subtarget->hasStdExtB()">,
  43. + AssemblerPredicate<(all_of FeatureStdExtB),
  44. + "'B' (Bit Manipulation Instructions)">;
  45. +
  46. def FeatureStdExtZbkb
  47. : SubtargetFeature<"zbkb", "HasStdExtZbkb", "true",
  48. "'Zbkb' (Bitmanip instructions for Cryptography)">;
  49. diff --git a/llvm/lib/Target/RISCV/RISCVSubtarget.h b/llvm/lib/Target/RISCV/RISCVSubtarget.h
  50. index a63c07597a2c..75d20193c9a0 100644
  51. --- a/llvm/lib/Target/RISCV/RISCVSubtarget.h
  52. +++ b/llvm/lib/Target/RISCV/RISCVSubtarget.h
  53. @@ -65,6 +65,7 @@ private:
  54. bool HasStdExtF = false;
  55. bool HasStdExtD = false;
  56. bool HasStdExtC = false;
  57. + bool HasStdExtB = false;
  58. bool HasStdExtZihintpause = false;
  59. bool HasStdExtZba = false;
  60. bool HasStdExtZbb = false;
  61. @@ -164,6 +165,7 @@ public:
  62. bool hasStdExtC() const { return HasStdExtC; }
  63. bool hasStdExtV() const { return HasStdExtV; }
  64. bool hasStdExtZihintpause() const { return HasStdExtZihintpause; }
  65. + bool hasStdExtB() const { return HasStdExtB; }
  66. bool hasStdExtZba() const { return HasStdExtZba; }
  67. bool hasStdExtZbb() const { return HasStdExtZbb; }
  68. bool hasStdExtZbc() const { return HasStdExtZbc; }
  69. --
  70. 2.25.1