[clang] [llvm] [RISCV] Implement Clang Builtins for XCValu Extension in CV32E40P (PR #100684)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 25 19:55:22 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 ac1a1e5797388598201511d17f05aa088ef4a2e2 5d0eb646fdf2925b9b0063f6f42c9447cd0eb460 --extensions c,cpp,h -- clang/lib/Headers/riscv_corev_alu.h clang/test/CodeGen/RISCV/riscv-xcvalu-c-api.c clang/test/CodeGen/RISCV/riscv-xcvalu.c clang/include/clang/Basic/TargetBuiltins.h clang/lib/Basic/Targets/RISCV.cpp clang/lib/CodeGen/CGBuiltin.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/Basic/TargetBuiltins.h b/clang/include/clang/Basic/TargetBuiltins.h
index ea3ab9dd1b..81140286a8 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -159,7 +159,7 @@ namespace clang {
#include "clang/Basic/BuiltinsRISCVXCV.def"
FirstTSBuiltin,
};
- }
+ } // namespace RISCVXCV
/// RISCV builtins
namespace RISCV {
diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp
index 05016095b8..97104998d8 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -231,12 +231,14 @@ static constexpr Builtin::Info BuiltinInfo[] = {
{#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsRISCVVector.def"
#define BUILTIN(ID, TYPE, ATTRS) \
- {"__builtin_riscv_cv_" #ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+ {"__builtin_riscv_cv_" #ID, TYPE, ATTRS, nullptr, \
+ HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
- {"__builtin_riscv_cv_" #ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+ {"__builtin_riscv_cv_" #ID, TYPE, ATTRS, FEATURE, \
+ HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsRISCVXCV.def"
-#define BUILTIN(ID, TYPE, ATTRS) \ \
- {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define BUILTIN(ID, TYPE, ATTRS) \
+ \ {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
{#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
#include "clang/Basic/BuiltinsRISCV.inc"
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index d37d1d420e..90727de597 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -22151,10 +22151,10 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID,
}
// Core-V
-#define BUILTIN(NAME, TYPE, ATTRS) \
-case RISCVXCV::BI__builtin_riscv_cv_##NAME: \
- ID = Intrinsic::riscv_cv_##NAME; \
- return EmitXCVIntrinsic(*this, BuiltinID, ID, Ops, E);
+#define BUILTIN(NAME, TYPE, ATTRS) \
+ case RISCVXCV::BI__builtin_riscv_cv_##NAME: \
+ ID = Intrinsic::riscv_cv_##NAME; \
+ return EmitXCVIntrinsic(*this, BuiltinID, ID, Ops, E);
#include "clang/Basic/BuiltinsRISCVXCV.def"
// Vector builtins are handled from here.
diff --git a/clang/lib/Headers/riscv_corev_alu.h b/clang/lib/Headers/riscv_corev_alu.h
index fd6e7106c0..d623002257 100644
--- a/clang/lib/Headers/riscv_corev_alu.h
+++ b/clang/lib/Headers/riscv_corev_alu.h
@@ -20,13 +20,16 @@ extern "C" {
#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
-static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_abs(long a) { return __builtin_abs(a); }
+static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_abs(long a) {
+ return __builtin_abs(a);
+}
static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_slet(long a, long b) {
return __builtin_riscv_cv_alu_slet(a, b);
}
-static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_sletu(unsigned long a, unsigned long b) {
+static __inline__ long __DEFAULT_FN_ATTRS
+__riscv_cv_alu_sletu(unsigned long a, unsigned long b) {
return __builtin_riscv_cv_alu_sletu(a, b);
}
@@ -34,7 +37,8 @@ static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_min(long a, long b) {
return __builtin_riscv_cv_alu_min(a, b);
}
-static __inline__ unsigned long __DEFAULT_FN_ATTRS __riscv_cv_alu_minu(unsigned long a, unsigned long b) {
+static __inline__ unsigned long __DEFAULT_FN_ATTRS
+__riscv_cv_alu_minu(unsigned long a, unsigned long b) {
return __builtin_riscv_cv_alu_minu(a, b);
}
@@ -42,63 +46,76 @@ static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_max(long a, long b) {
return __builtin_riscv_cv_alu_max(a, b);
}
-static __inline__ unsigned long __DEFAULT_FN_ATTRS __riscv_cv_alu_maxu(unsigned long a, unsigned long b) {
+static __inline__ unsigned long __DEFAULT_FN_ATTRS
+__riscv_cv_alu_maxu(unsigned long a, unsigned long b) {
return __builtin_riscv_cv_alu_maxu(a, b);
}
-static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_exths(int16_t a) { return __builtin_riscv_cv_alu_exths(a); }
+static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_exths(int16_t a) {
+ return __builtin_riscv_cv_alu_exths(a);
+}
-static __inline__ unsigned long __DEFAULT_FN_ATTRS __riscv_cv_alu_exthz(uint16_t a) {
+static __inline__ unsigned long __DEFAULT_FN_ATTRS
+__riscv_cv_alu_exthz(uint16_t a) {
return __builtin_riscv_cv_alu_exthz(a);
}
-static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_extbs(int8_t a) { return __builtin_riscv_cv_alu_extbs(a); }
+static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_extbs(int8_t a) {
+ return __builtin_riscv_cv_alu_extbs(a);
+}
-static __inline__ unsigned long __DEFAULT_FN_ATTRS __riscv_cv_alu_extbz(uint8_t a) {
+static __inline__ unsigned long __DEFAULT_FN_ATTRS
+__riscv_cv_alu_extbz(uint8_t a) {
return __builtin_riscv_cv_alu_extbz(a);
}
-static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_clip(long a, unsigned long b) {
+static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_clip(long a,
+ unsigned long b) {
return __builtin_riscv_cv_alu_clip(a, b);
}
-static __inline__ unsigned long __DEFAULT_FN_ATTRS __riscv_cv_alu_clipu(unsigned long a, unsigned long b) {
+static __inline__ unsigned long __DEFAULT_FN_ATTRS
+__riscv_cv_alu_clipu(unsigned long a, unsigned long b) {
return __builtin_riscv_cv_alu_clipu(a, b);
}
-static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_addN(long a, long b, uint8_t shft) {
+static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_addN(long a, long b,
+ uint8_t shft) {
return __builtin_riscv_cv_alu_addN(a, b, shft);
}
-static __inline__ unsigned long __DEFAULT_FN_ATTRS __riscv_cv_alu_adduN(unsigned long a, unsigned long b,
- uint8_t shft) {
+static __inline__ unsigned long __DEFAULT_FN_ATTRS
+__riscv_cv_alu_adduN(unsigned long a, unsigned long b, uint8_t shft) {
return __builtin_riscv_cv_alu_adduN(a, b, shft);
}
-static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_addRN(long a, long b, uint8_t shft) {
+static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_addRN(long a, long b,
+ uint8_t shft) {
return __builtin_riscv_cv_alu_addRN(a, b, shft);
}
-static __inline__ unsigned long __DEFAULT_FN_ATTRS __riscv_cv_alu_adduRN(unsigned long a, unsigned long b,
- uint8_t shft) {
+static __inline__ unsigned long __DEFAULT_FN_ATTRS
+__riscv_cv_alu_adduRN(unsigned long a, unsigned long b, uint8_t shft) {
return __builtin_riscv_cv_alu_adduRN(a, b, shft);
}
-static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_subN(long a, long b, uint8_t shft) {
+static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_subN(long a, long b,
+ uint8_t shft) {
return __builtin_riscv_cv_alu_subN(a, b, shft);
}
-static __inline__ unsigned long __DEFAULT_FN_ATTRS __riscv_cv_alu_subuN(unsigned long a, unsigned long b,
- uint8_t shft) {
+static __inline__ unsigned long __DEFAULT_FN_ATTRS
+__riscv_cv_alu_subuN(unsigned long a, unsigned long b, uint8_t shft) {
return __builtin_riscv_cv_alu_subuN(a, b, shft);
}
-static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_subRN(long a, long b, uint8_t shft) {
+static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_subRN(long a, long b,
+ uint8_t shft) {
return __builtin_riscv_cv_alu_subRN(a, b, shft);
}
-static __inline__ unsigned long __DEFAULT_FN_ATTRS __riscv_cv_alu_subuRN(unsigned long a, unsigned long b,
- uint8_t shft) {
+static __inline__ unsigned long __DEFAULT_FN_ATTRS
+__riscv_cv_alu_subuRN(unsigned long a, unsigned long b, uint8_t shft) {
return __builtin_riscv_cv_alu_subuRN(a, b, shft);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/100684
More information about the llvm-commits
mailing list