[clang] 02bdbdc - [clang][SveEmitter] Fix enum declarations. [NFCI]

Francesco Petrogalli via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 16 06:50:37 PST 2020


Author: Francesco Petrogalli
Date: 2020-11-16T14:49:45Z
New Revision: 02bdbdc76021fcfb8cae465363b362cb889406d2

URL: https://github.com/llvm/llvm-project/commit/02bdbdc76021fcfb8cae465363b362cb889406d2
DIFF: https://github.com/llvm/llvm-project/commit/02bdbdc76021fcfb8cae465363b362cb889406d2.diff

LOG: [clang][SveEmitter] Fix enum declarations. [NFCI]

Adapt the declarations of `svpattern` and `svprfop` to the most recent
one defined in section "5. Enum declarations" of the SVE ACLE
specifications [1].

The signature of the intrinsics using these enums have been changed
accordingly.

A test has been added to make sure that `svpattern` and `svprfop` are
not typedefs.

[1] https://developer.arm.com/documentation/100987/latest, version
00bet6

Reviewed By: joechrisellis

Differential Revision: https://reviews.llvm.org/D91333

Added: 
    clang/test/Sema/aarch64-sve-enums.c

Modified: 
    clang/utils/TableGen/SveEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/Sema/aarch64-sve-enums.c b/clang/test/Sema/aarch64-sve-enums.c
new file mode 100644
index 000000000000..01b110645f1f
--- /dev/null
+++ b/clang/test/Sema/aarch64-sve-enums.c
@@ -0,0 +1,19 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns  -fsyntax-only -verify
+// expected-no-diagnostics
+
+// This test makes sure that the enum declarations in section "5. Enum
+// declarations" of the SVE ACLE [1] are not presented as typedefs in
+// `arm_sve.h`. It does so by creating a typedef'd struct with the
+// same identifier as the one defined in `arm_sve.h`, then checking that
+// it does not overload the enum defined in `arm_sve.h`.
+//
+// [1] https://developer.arm.com/documentation/100987/latest version 00bet6
+
+typedef struct { float f; } svpattern;
+typedef struct { float f; } svprfop;
+#include <arm_sve.h>
+enum svpattern a1 = SV_ALL;
+svpattern b1 = {1.0f};
+enum svprfop a2 = SV_PLDL1KEEP;
+svprfop b2 = {1.0f};

diff  --git a/clang/utils/TableGen/SveEmitter.cpp b/clang/utils/TableGen/SveEmitter.cpp
index 1d42edd8a94a..8a705bc4b5b8 100644
--- a/clang/utils/TableGen/SveEmitter.cpp
+++ b/clang/utils/TableGen/SveEmitter.cpp
@@ -416,10 +416,10 @@ std::string SVEType::builtin_str() const {
 
 std::string SVEType::str() const {
   if (isPredicatePattern())
-    return "sv_pattern";
+    return "enum svpattern";
 
   if (isPrefetchOp())
-    return "sv_prfop";
+    return "enum svprfop";
 
   std::string S;
   if (Void)
@@ -1163,7 +1163,7 @@ void SVEEmitter::createHeader(raw_ostream &OS) {
   OS << "typedef __clang_svbfloat16x4_t svbfloat16x4_t;\n";
   OS << "#endif\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svpattern\n";
   OS << "{\n";
   OS << "  SV_POW2 = 0,\n";
   OS << "  SV_VL1 = 1,\n";
@@ -1182,9 +1182,9 @@ void SVEEmitter::createHeader(raw_ostream &OS) {
   OS << "  SV_MUL4 = 29,\n";
   OS << "  SV_MUL3 = 30,\n";
   OS << "  SV_ALL = 31\n";
-  OS << "} sv_pattern;\n\n";
+  OS << "};\n\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svprfop\n";
   OS << "{\n";
   OS << "  SV_PLDL1KEEP = 0,\n";
   OS << "  SV_PLDL1STRM = 1,\n";
@@ -1198,7 +1198,7 @@ void SVEEmitter::createHeader(raw_ostream &OS) {
   OS << "  SV_PSTL2STRM = 11,\n";
   OS << "  SV_PSTL3KEEP = 12,\n";
   OS << "  SV_PSTL3STRM = 13\n";
-  OS << "} sv_prfop;\n\n";
+  OS << "};\n\n";
 
   OS << "/* Function attributes */\n";
   OS << "#define __aio static inline __attribute__((__always_inline__, "


        


More information about the cfe-commits mailing list