From 90111f79f9f34e0ba488c1453e2e3b57db2553e7 Mon Sep 17 00:00:00 2001 From: James Molloy Date: Thu, 12 Nov 2015 12:29:09 +0000 Subject: [SDAG] Introduce a new BITREVERSE node along with a corresponding LLVM intrinsic Several backends have instructions to reverse the order of bits in an integer. Conceptually matching such patterns is similar to @llvm.bswap, and it was mentioned in http://reviews.llvm.org/D14234 that it would be best if these patterns were matched in InstCombine instead of reimplemented in every different target. This patch introduces an intrinsic @llvm.bitreverse.i* that operates similarly to @llvm.bswap. For plumbing purposes there is also a new ISD node ISD::BITREVERSE, with simple expansion and promotion support. The intention is that InstCombine's BSWAP detection logic will be extended to support BITREVERSE too, and @llvm.bitreverse intrinsics emitted (if the backend supports lowering it efficiently). llvm-svn: 252878 --- llvm/docs/LangRef.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'llvm/docs/LangRef.rst') diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index 0e4eae0df80..5273bf0ac11 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -10417,6 +10417,34 @@ Bit Manipulation Intrinsics LLVM provides intrinsics for a few important bit manipulation operations. These allow efficient code generation for some algorithms. +'``llvm.bitreverse.*``' Intrinsics +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Syntax: +""""""" + +This is an overloaded intrinsic function. You can use bitreverse on any +integer type. + +:: + + declare i16 @llvm.bitreverse.i16(i16 ) + declare i32 @llvm.bitreverse.i32(i32 ) + declare i64 @llvm.bitreverse.i64(i64 ) + +Overview: +""""""""" + +The '``llvm.bitreverse``' family of intrinsics is used to reverse the +bitpattern of an integer value; for example ``0b1234567`` becomes +``0b7654321``. + +Semantics: +"""""""""" + +The ``llvm.bitreverse.iN`` intrinsic returns an i16 value that has bit +``M`` in the input moved to bit ``N-M`` in the output. + '``llvm.bswap.*``' Intrinsics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- cgit v1.2.3