[PATCH] D148822: [clang][BFloat] Avoid redefining bfloat16_t in arm_neon.h

Dimitry Andric via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 20 11:12:11 PDT 2023


dim created this revision.
dim added reviewers: t.p.northover, fpetrogalli, sdesmalen, az, LukeGeeson, stuij.
Herald added a project: All.
dim requested review of this revision.
Herald added a project: clang.

As of https://reviews.llvm.org/D79708, clang-tblgen generates both
`arm_neon.h` and `arm_bf16.h`, and both generated files will contain a
typedef of `bfloat16_t`. However, `arm_neon.h` includes `arm_bf16.h`
immediately before its own typedef:

  #include <arm_bf16.h>
  typedef __bf16 bfloat16_t;

With a recent version of clang (I used 16.0.1) this results in warnings:

  /usr/lib/clang/16/include/arm_neon.h:38:16: error: redefinition of typedef 'bfloat16_t' is a C11 feature [-Werror,-Wtypedef-redefinition]

Since `arm_bf16.h` is very likely supposed to be the one true place
where `bfloat16_t` is defined, I propose to delete the duplicate typedef
from the generated `arm_neon.h`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148822

Files:
  clang/utils/TableGen/NeonEmitter.cpp


Index: clang/utils/TableGen/NeonEmitter.cpp
===================================================================
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -2353,7 +2353,6 @@
   OS << "#include <stdint.h>\n\n";
 
   OS << "#include <arm_bf16.h>\n";
-  OS << "typedef __bf16 bfloat16_t;\n";
 
   // Emit NEON-specific scalar typedefs.
   OS << "typedef float float32_t;\n";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148822.515398.patch
Type: text/x-patch
Size: 414 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230420/cbe2d008/attachment.bin>


More information about the cfe-commits mailing list