forked from OSchip/llvm-project
[RISCV] Make use of the required features in BuiltinInfo to store that V extension builtins require 'experimental-v'.
Use that to print the diagnostic in SemaChecking instead of listing all of the builtins in a switch. With the required features, IR generation will also be able to error on this. Checking this here allows us to have a RISCV focused error message. Reviewed By: HsiangKai Differential Revision: https://reviews.llvm.org/D97826
This commit is contained in:
parent
584cb67d2d
commit
201ebf211f
|
@ -11,8 +11,12 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#if defined(BUILTIN) && !defined(RISCVV_BUILTIN)
|
#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
|
||||||
#define RISCVV_BUILTIN(ID, TYPE, ATTRS) BUILTIN(ID, TYPE, ATTRS)
|
# 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
|
#endif
|
||||||
|
|
||||||
RISCVV_BUILTIN(__builtin_rvv_vadd_vv_i8m1_vl, "q8Scq8Scq8Scz", "n")
|
RISCVV_BUILTIN(__builtin_rvv_vadd_vv_i8m1_vl, "q8Scq8Scq8Scz", "n")
|
||||||
|
|
|
@ -201,6 +201,8 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
|
||||||
const Builtin::Info RISCVTargetInfo::BuiltinInfo[] = {
|
const Builtin::Info RISCVTargetInfo::BuiltinInfo[] = {
|
||||||
#define BUILTIN(ID, TYPE, ATTRS) \
|
#define BUILTIN(ID, TYPE, ATTRS) \
|
||||||
{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
|
{#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"
|
#include "clang/Basic/BuiltinsRISCV.def"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3392,16 +3392,13 @@ bool Sema::CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID,
|
||||||
bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI,
|
bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI,
|
||||||
unsigned BuiltinID,
|
unsigned BuiltinID,
|
||||||
CallExpr *TheCall) {
|
CallExpr *TheCall) {
|
||||||
switch (BuiltinID) {
|
// CodeGenFunction can also detect this, but this gives a better error
|
||||||
default:
|
// message.
|
||||||
break;
|
StringRef Features = Context.BuiltinInfo.getRequiredFeatures(BuiltinID);
|
||||||
#define RISCVV_BUILTIN(ID, TYPE, ATTRS) case RISCV::BI##ID:
|
if (Features.find("experimental-v") != StringRef::npos &&
|
||||||
#include "clang/Basic/BuiltinsRISCV.def"
|
!TI.hasFeature("experimental-v"))
|
||||||
if (!TI.hasFeature("experimental-v"))
|
return Diag(TheCall->getBeginLoc(), diag::err_riscvv_builtin_requires_v)
|
||||||
return Diag(TheCall->getBeginLoc(), diag::err_riscvv_builtin_requires_v)
|
<< TheCall->getSourceRange();
|
||||||
<< TheCall->getSourceRange();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue