[clang] 204aaf8 - [AArch64][SVE] Always use overloaded methods instead of preprocessor macro.
Sander de Smalen via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 13 13:13:25 PDT 2021
Author: Sander de Smalen
Date: 2021-04-13T21:12:53+01:00
New Revision: 204aaf879548616df407f662bc03d28b8d08d1fb
URL: https://github.com/llvm/llvm-project/commit/204aaf879548616df407f662bc03d28b8d08d1fb
DIFF: https://github.com/llvm/llvm-project/commit/204aaf879548616df407f662bc03d28b8d08d1fb.diff
LOG: [AArch64][SVE] Always use overloaded methods instead of preprocessor macro.
This fixes a subtle issue where:
svprf(pg, ptr, SV_ALL /*is sv_pattern instead of sv_prfop*/)
would be quietly accepted. With this change, the function declaration
guards that the third parameter is a `enum sv_prfop`. Previously `svprf`
would map directly to `__builtin_sve_svprfb`, which accepts the enum
operand as a signed integer and only checks that the incoming range is
valid, meaning that SV_ALL would be discarded as being outside the valid
immediate range, but would have allowed SV_VL1 without issuing a warning
(C) or error (C++).
Reviewed By: c-rhodes
Differential Revision: https://reviews.llvm.org/D100297
Added:
Modified:
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfb.c
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfd.c
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfh.c
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfw.c
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdecb.c
clang/utils/TableGen/SveEmitter.cpp
Removed:
################################################################################
diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfb.c b/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfb.c
index e8815a05c3a57..641bbff06aa52 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfb.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfb.c
@@ -10,7 +10,7 @@ void test_svprfb(svbool_t pg, const void *base)
void test_svprfb_1(svbool_t pg, const void *base)
{
- // expected-error at +1 {{argument value -1 is outside the valid range [0, 13]}}
+ // expected-error-re at +1 {{argument value {{.*}} is outside the valid range [0, 13]}}
return svprfb(pg, base, -1);
}
@@ -22,6 +22,12 @@ void test_svprfb_vnum(svbool_t pg, const void *base)
void test_svprfb_vnum_1(svbool_t pg, const void *base)
{
- // expected-error at +1 {{argument value -1 is outside the valid range [0, 13]}}
+ // expected-error-re at +1 {{argument value {{.*}} is outside the valid range [0, 13]}}
return svprfb_vnum(pg, base, 0, -1);
}
+
+void test_svprfb_svpattern(svbool_t pg, const void *base)
+{
+ // expected-warning at +1 {{implicit conversion from enumeration type 'enum svpattern' to
diff erent enumeration type 'enum svprfop'}}
+ return svprfb(pg, base, SV_VL1);
+}
diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfd.c b/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfd.c
index cd15ac58d9614..e1ad02d812ad1 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfd.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfd.c
@@ -10,7 +10,7 @@ void test_svprfd(svbool_t pg, const void *base)
void test_svprfd_1(svbool_t pg, const void *base)
{
- // expected-error at +1 {{argument value -1 is outside the valid range [0, 13]}}
+ // expected-error-re at +1 {{argument value {{.*}} is outside the valid range [0, 13]}}
return svprfd(pg, base, -1);
}
@@ -22,6 +22,6 @@ void test_svprfd_vnum(svbool_t pg, const void *base)
void test_svprfd_vnum_1(svbool_t pg, const void *base)
{
- // expected-error at +1 {{argument value -1 is outside the valid range [0, 13]}}
+ // expected-error-re at +1 {{argument value {{.*}} is outside the valid range [0, 13]}}
return svprfd_vnum(pg, base, 0, -1);
}
diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfh.c b/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfh.c
index c18b66f06529b..7ffff9b08e4a1 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfh.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfh.c
@@ -10,7 +10,7 @@ void test_svprfh(svbool_t pg, const void *base)
void test_svprfh_1(svbool_t pg, const void *base)
{
- // expected-error at +1 {{argument value -1 is outside the valid range [0, 13]}}
+ // expected-error-re at +1 {{argument value {{.*}} is outside the valid range [0, 13]}}
return svprfh(pg, base, -1);
}
@@ -22,6 +22,6 @@ void test_svprfh_vnum(svbool_t pg, const void *base)
void test_svprfh_vnum_1(svbool_t pg, const void *base)
{
- // expected-error at +1 {{argument value -1 is outside the valid range [0, 13]}}
+ // expected-error-re at +1 {{argument value {{.*}} is outside the valid range [0, 13]}}
return svprfh_vnum(pg, base, 0, -1);
}
diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfw.c b/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfw.c
index 6e3c27a488599..8ce509784ccda 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfw.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfw.c
@@ -10,7 +10,7 @@ void test_svprfw(svbool_t pg, const void *base)
void test_svprfw_1(svbool_t pg, const void *base)
{
- // expected-error at +1 {{argument value -1 is outside the valid range [0, 13]}}
+ // expected-error-re at +1 {{argument value {{.*}} is outside the valid range [0, 13]}}
return svprfw(pg, base, -1);
}
@@ -22,6 +22,6 @@ void test_svprfw_vnum(svbool_t pg, const void *base)
void test_svprfw_vnum_1(svbool_t pg, const void *base)
{
- // expected-error at +1 {{argument value -1 is outside the valid range [0, 13]}}
+ // expected-error-re at +1 {{argument value {{.*}} is outside the valid range [0, 13]}}
return svprfw_vnum(pg, base, 0, -1);
}
diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdecb.c b/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdecb.c
index 2878a6fa35b68..e07094c5ed525 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdecb.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdecb.c
@@ -105,3 +105,9 @@ uint64_t test_svqdecb_pat_n_u64_1(uint64_t op)
// expected-error-re at +1 {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
return SVE_ACLE_FUNC(svqdecb_pat,_n_u64,,)(op, SV_VL7, 17);
}
+
+uint64_t test_svqdecb_svprfop(uint64_t op)
+{
+ // expected-warning at +1 {{implicit conversion from enumeration type 'enum svprfop' to
diff erent enumeration type 'enum svpattern'}}
+ return SVE_ACLE_FUNC(svqdecb_pat,_n_u64,,)(op, SV_PLDL1KEEP, 1);
+}
diff --git a/clang/utils/TableGen/SveEmitter.cpp b/clang/utils/TableGen/SveEmitter.cpp
index 46966d4d9feb1..b2f6ede56522a 100644
--- a/clang/utils/TableGen/SveEmitter.cpp
+++ b/clang/utils/TableGen/SveEmitter.cpp
@@ -919,26 +919,22 @@ std::string Intrinsic::mangleName(ClassKind LocalCK) const {
}
void Intrinsic::emitIntrinsic(raw_ostream &OS) const {
- // Use the preprocessor to
- if (getClassKind() != ClassG || getProto().size() <= 1) {
- OS << "#define " << mangleName(getClassKind())
- << "(...) __builtin_sve_" << mangleName(ClassS)
- << "(__VA_ARGS__)\n";
- } else {
- std::string FullName = mangleName(ClassS);
- std::string ProtoName = mangleName(ClassG);
+ bool IsOverloaded = getClassKind() == ClassG && getProto().size() > 1;
- OS << "__aio __attribute__((__clang_arm_builtin_alias("
- << "__builtin_sve_" << FullName << ")))\n";
+ std::string FullName = mangleName(ClassS);
+ std::string ProtoName = mangleName(getClassKind());
- OS << getTypes()[0].str() << " " << ProtoName << "(";
- for (unsigned I = 0; I < getTypes().size() - 1; ++I) {
- if (I != 0)
- OS << ", ";
- OS << getTypes()[I + 1].str();
- }
- OS << ");\n";
+ OS << (IsOverloaded ? "__aio " : "__ai ")
+ << "__attribute__((__clang_arm_builtin_alias("
+ << "__builtin_sve_" << FullName << ")))\n";
+
+ OS << getTypes()[0].str() << " " << ProtoName << "(";
+ for (unsigned I = 0; I < getTypes().size() - 1; ++I) {
+ if (I != 0)
+ OS << ", ";
+ OS << getTypes()[I + 1].str();
}
+ OS << ");\n";
}
//===----------------------------------------------------------------------===//
@@ -1204,6 +1200,8 @@ void SVEEmitter::createHeader(raw_ostream &OS) {
OS << "};\n\n";
OS << "/* Function attributes */\n";
+ OS << "#define __ai static __inline__ __attribute__((__always_inline__, "
+ "__nodebug__))\n\n";
OS << "#define __aio static __inline__ __attribute__((__always_inline__, "
"__nodebug__, __overloadable__))\n\n";
More information about the cfe-commits
mailing list