[PATCH] D97826: [RISCV] Make use of the required features in BuiltinInfo to store that V extension builtins require 'experimental-v'.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 3 16:40:29 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG201ebf211f97: [RISCV] Make use of the required features in BuiltinInfo to store that V… (authored by craig.topper).
Changed prior to commit:
https://reviews.llvm.org/D97826?vs=327645&id=327965#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97826/new/
https://reviews.llvm.org/D97826
Files:
clang/include/clang/Basic/BuiltinsRISCV.def
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Sema/SemaChecking.cpp
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3392,16 +3392,13 @@
bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI,
unsigned BuiltinID,
CallExpr *TheCall) {
- switch (BuiltinID) {
- default:
- break;
-#define RISCVV_BUILTIN(ID, TYPE, ATTRS) case RISCV::BI##ID:
-#include "clang/Basic/BuiltinsRISCV.def"
- if (!TI.hasFeature("experimental-v"))
- return Diag(TheCall->getBeginLoc(), diag::err_riscvv_builtin_requires_v)
- << TheCall->getSourceRange();
- break;
- }
+ // CodeGenFunction can also detect this, but this gives a better error
+ // message.
+ StringRef Features = Context.BuiltinInfo.getRequiredFeatures(BuiltinID);
+ if (Features.find("experimental-v") != StringRef::npos &&
+ !TI.hasFeature("experimental-v"))
+ return Diag(TheCall->getBeginLoc(), diag::err_riscvv_builtin_requires_v)
+ << TheCall->getSourceRange();
return false;
}
Index: clang/lib/Basic/Targets/RISCV.cpp
===================================================================
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -201,6 +201,8 @@
const Builtin::Info RISCVTargetInfo::BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) \
{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+ {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE},
#include "clang/Basic/BuiltinsRISCV.def"
};
Index: clang/include/clang/Basic/BuiltinsRISCV.def
===================================================================
--- clang/include/clang/Basic/BuiltinsRISCV.def
+++ clang/include/clang/Basic/BuiltinsRISCV.def
@@ -11,8 +11,12 @@
//
//===----------------------------------------------------------------------===//
-#if defined(BUILTIN) && !defined(RISCVV_BUILTIN)
-#define RISCVV_BUILTIN(ID, TYPE, ATTRS) BUILTIN(ID, TYPE, ATTRS)
+#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
+# define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
+#if defined(TARGET_BUILTIN) && !defined(RISCVV_BUILTIN)
+#define RISCVV_BUILTIN(ID, TYPE, ATTRS) TARGET_BUILTIN(ID, TYPE, ATTRS, "experimental-v")
#endif
RISCVV_BUILTIN(__builtin_rvv_vadd_vv_i8m1_vl, "q8Scq8Scq8Scz", "n")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97826.327965.patch
Type: text/x-patch
Size: 2526 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210304/e2c12597/attachment.bin>
More information about the llvm-commits
mailing list