r264203 - Add missing __builtin_bitreverse8
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 23 15:14:43 PDT 2016
Author: arsenm
Date: Wed Mar 23 17:14:43 2016
New Revision: 264203
URL: http://llvm.org/viewvc/llvm-project?rev=264203&view=rev
Log:
Add missing __builtin_bitreverse8
Also add documentation for bitreverse builtins
Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins.c
Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=264203&r1=264202&r2=264203&view=diff
==============================================================================
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Wed Mar 23 17:14:43 2016
@@ -1505,6 +1505,33 @@ C-style cast applied to each element of
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 ``0b10110110`` becomes
+``0b01101101``.
+
``__builtin_unreachable``
-------------------------
Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=264203&r1=264202&r2=264203&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Wed Mar 23 17:14:43 2016
@@ -409,6 +409,7 @@ BUILTIN(__builtin_bswap16, "UsUs", "nc")
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")
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=264203&r1=264202&r2=264203&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Mar 23 17:14:43 2016
@@ -681,6 +681,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
case Builtin::BI__builtin_bswap64: {
return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::bswap));
}
+ case Builtin::BI__builtin_bitreverse8:
case Builtin::BI__builtin_bitreverse16:
case Builtin::BI__builtin_bitreverse32:
case Builtin::BI__builtin_bitreverse64: {
Modified: cfe/trunk/test/CodeGen/builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=264203&r1=264202&r2=264203&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Wed Mar 23 17:14:43 2016
@@ -117,9 +117,11 @@ int main() {
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));
More information about the cfe-commits
mailing list