[PATCH] D91333: [clang][SveEmitter] Fix enum declarations. [NFCI]

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


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG02bdbdc76021: [clang][SveEmitter] Fix enum declarations. [NFCI] (authored by fpetrogalli).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91333/new/

https://reviews.llvm.org/D91333

Files:
  clang/test/Sema/aarch64-sve-enums.c
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===================================================================
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -416,10 +416,10 @@
 
 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 @@
   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 @@
   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 @@
   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__, "
Index: clang/test/Sema/aarch64-sve-enums.c
===================================================================
--- /dev/null
+++ 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};


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91333.305496.patch
Type: text/x-patch
Size: 2288 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201116/fa310935/attachment.bin>


More information about the cfe-commits mailing list