[PATCH] D61845: [builtin] Fixed definitions of builtins that rely on the int/long long type is 32/64 bits

Karl-Johan Karlsson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun May 12 23:47:34 PDT 2019


Ka-Ka created this revision.
Ka-Ka added reviewers: dylanmckay, spatel, rsmith.
Herald added a subscriber: kristina.
Herald added a project: clang.

The definition of the builtins __builtin_bswap32, __builtin_bitreverse32, __builtin_rotateleft32 and __builtin_rotateright32 rely on that the int type is 32 bits wide on the target.
The defintions of the builtins __builtin_bswap64, __builtin_bitreverse64, __builtin_rotateleft64, and __builtin_rotateright64 rely on that the long long type is 64 bits wide.

On targets where this is not the case (e.g. AVR) clang will generate faulty code (wrong llvm assembler intrinsics).

This patch add support for using 'Z' (the int32_t type) in Bultins.def. The builtins above are changed to be based on the int32_t type instead of the int type, and the int64_t type instead of the long long type.

The AVR backend (experimental) have a native int type that is only 16 bits wide. The supplied testcase will therefore fail if running the testcase on trunk as clang will convert e.g. __builtin_bitreverse32 into llvm.bitreverse.i16 on AVR.


Repository:
  rC Clang

https://reviews.llvm.org/D61845

Files:
  include/clang/Basic/Builtins.def
  lib/AST/ASTContext.cpp
  test/CodeGen/avr-builtins.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61845.199207.patch
Type: text/x-patch
Size: 7540 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190513/a5447825/attachment.bin>


More information about the cfe-commits mailing list