[clang] [llvm] [WIP][RISCV] Support __builtin_cpu_init and __builtin_cpu_supports (PR #99700)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 19 13:33:42 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 5e8cd29d62a72ed18e7bc782554d7f14eccec0ee ddf2c58a864576586b89cc611e2bea15b8cf18ba --extensions h,cpp -- clang/lib/Basic/Targets/RISCV.cpp clang/lib/Basic/Targets/RISCV.h clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CodeGenFunction.h llvm/include/llvm/TargetParser/RISCVISAInfo.h llvm/lib/TargetParser/RISCVISAInfo.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 71c947776a..25dbe22132 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14289,8 +14289,7 @@ Value *CodeGenFunction::EmitRISCVCpuSupports(const CallExpr *E) {
   // Note: We are making an unchecked assumption that the size of the
   // feature array is >= 1.  This holds for any version of compiler-rt
   // which defines this interface.
-  llvm::ArrayType *ArrayOfInt64Ty =
-      llvm::ArrayType::get(Int64Ty, 1);
+  llvm::ArrayType *ArrayOfInt64Ty = llvm::ArrayType::get(Int64Ty, 1);
   llvm::Type *StructTy = llvm::StructType::get(Int32Ty, ArrayOfInt64Ty);
   llvm::Constant *RISCVFeaturesBits =
       CGM.CreateRuntimeVariable(StructTy, "__riscv_feature_bits");
diff --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp
index 3ff1b32579..7a5b10a877 100644
--- a/llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -1030,48 +1030,27 @@ struct RISCVExtBit {
 /// __riscv_features_bits to their respective bit position.  At the
 /// moment all extensions are within group 0.
 static RISCVExtBit RISCVGroup0BitPositions[] = {
-  {"a", 0},
-  {"c", 2},
-  {"d", 3},
-  {"f", 5},
-  {"i", 8},
-  {"m", 12},
-  {"v", 21},
-  {"zacas", 26},
-  {"zba", 27},
-  {"zbb", 28},
-  {"zbc", 29},
-  {"zbkb", 30},
-  {"zbkc", 31},
-  {"zbkx", 32},
-  {"zbs", 33},
-  {"zfa", 34},
-  {"zfh", 35},
-  {"zfhmin", 36},
-  {"zicboz", 37},
-  {"zicond", 38},
-  {"zihintntl", 39},
-  {"zihintpause", 40},
-  {"zknd", 41},
-  {"zkne", 42},
-  {"zknh", 43},
-  {"zksed", 44},
-  {"zksh", 45},
-  {"zkt", 46},
-  {"ztso", 47},
-  {"zvbb", 48},
-  {"zvbc", 49},
-  {"zvfh", 50},
-  {"zvfhmin", 51},
-  {"zvkb", 52},
-  {"zvkg", 53},
-  {"zvkned", 54},
-  {"zvknha", 55},
-  {"zvknhb", 56},
-  {"zvksed", 57},
-  {"zvksh", 58},
-  {"zvkt", 59}
-};
+    {"a", 0},          {"c", 2},
+    {"d", 3},          {"f", 5},
+    {"i", 8},          {"m", 12},
+    {"v", 21},         {"zacas", 26},
+    {"zba", 27},       {"zbb", 28},
+    {"zbc", 29},       {"zbkb", 30},
+    {"zbkc", 31},      {"zbkx", 32},
+    {"zbs", 33},       {"zfa", 34},
+    {"zfh", 35},       {"zfhmin", 36},
+    {"zicboz", 37},    {"zicond", 38},
+    {"zihintntl", 39}, {"zihintpause", 40},
+    {"zknd", 41},      {"zkne", 42},
+    {"zknh", 43},      {"zksed", 44},
+    {"zksh", 45},      {"zkt", 46},
+    {"ztso", 47},      {"zvbb", 48},
+    {"zvbc", 49},      {"zvfh", 50},
+    {"zvfhmin", 51},   {"zvkb", 52},
+    {"zvkg", 53},      {"zvkned", 54},
+    {"zvknha", 55},    {"zvknhb", 56},
+    {"zvksed", 57},    {"zvksh", 58},
+    {"zvkt", 59}};
 int RISCVISAInfo::getRISCVFeaturesBitPosition(StringRef Ext) {
   // Note that this code currently accepts mixed case extension names, but
   // does not handle extension versions at all.  That's probably fine because

``````````

</details>


https://github.com/llvm/llvm-project/pull/99700


More information about the cfe-commits mailing list