[PATCH] D16993: Add missing __builtin_bitreverse8

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 7 07:33:27 PST 2016


arsenm retitled this revision from "Add documentation for bitreverse builtins" to "Add missing __builtin_bitreverse8".
arsenm updated the summary for this revision.
arsenm updated this revision to Diff 49960.

http://reviews.llvm.org/D16993

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/Builtins.def
  test/CodeGen/builtins.c

Index: test/CodeGen/builtins.c
===================================================================
--- test/CodeGen/builtins.c
+++ test/CodeGen/builtins.c
@@ -117,9 +117,11 @@
   P(bswap32, (N));
   P(bswap64, (N));
 
+  // CHECK: @llvm.bitreverse.i8
   // CHECK: @llvm.bitreverse.i16
   // CHECK: @llvm.bitreverse.i32
   // CHECK: @llvm.bitreverse.i64
+  P(bitreverse8, (N));
   P(bitreverse16, (N));
   P(bitreverse32, (N));
   P(bitreverse64, (N));
Index: include/clang/Basic/Builtins.def
===================================================================
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -409,6 +409,7 @@
 BUILTIN(__builtin_bswap32, "UiUi", "nc")
 BUILTIN(__builtin_bswap64, "ULLiULLi", "nc")
 
+BUILTIN(__builtin_bitreverse8, "UcUc", "nc")
 BUILTIN(__builtin_bitreverse16, "UsUs", "nc")
 BUILTIN(__builtin_bitreverse32, "UiUi", "nc")
 BUILTIN(__builtin_bitreverse64, "ULLiULLi", "nc")
Index: docs/LanguageExtensions.rst
===================================================================
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1505,6 +1505,33 @@
 
 Query for this feature with ``__has_builtin(__builtin_convertvector)``.
 
+``__builtin_bitreverse``
+---------------------
+
+* ``__builtin_bitreverse8``
+* ``__builtin_bitreverse16``
+* ``__builtin_bitreverse32``
+* ``__builtin_bitreverse64``
+
+**Syntax**:
+
+.. code-block:: c++
+     __builtin_bitreverse32(x)
+
+**Examples**:
+
+.. code-block:: c++
+      uint8_t rev_x = __builtin_bitreverse8(x);
+      uint16_t rev_x = __builtin_bitreverse16(x);
+      uint32_t rev_y = __builtin_bitreverse32(y);
+      uint64_t rev_z = __builtin_bitreverse64(z);
+
+**Description**:
+
+The '``__builtin_bitreverse``' family of builtins is used to reverse
+the bitpattern of an integer value; for example ``0b1234567`` becomes
+``0b7654321``.
+
 ``__builtin_unreachable``
 -------------------------
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16993.49960.patch
Type: text/x-patch
Size: 1921 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160307/e409e2e5/attachment-0001.bin>


More information about the cfe-commits mailing list