[clang] [CIR] Add bit reverse and byte reverse operations (PR #147200)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 8 05:23:38 PDT 2025
================
@@ -2661,6 +2661,55 @@ def BitPopcountOp : CIR_BitOpBase<"bit.popcnt",
}];
}
+def BitReverseOp : CIR_BitOpBase<"bit.reverse", CIR_UIntOfWidths<[8, 16, 32, 64]>> {
+ let summary = "Reverse the bit pattern of the operand integer";
+ let description = [{
+ The `cir.bit.reverse` operation reverses the bits of the operand integer.
+ Its only argument must be of unsigned integer types of width 8, 16, 32, or
+ 64.
+
+ This operation covers the C/C++ builtin function `__builtin_bitreverse`.
+
+ Example:
+
+ ```mlir
+ %1 = cir.bit.reverse %0 : !u32i
+ ```
+ }];
+}
+
+//===----------------------------------------------------------------------===//
+// ByteswapOp
+//===----------------------------------------------------------------------===//
+
+def ByteSwapOp : CIR_Op<"bswap", [Pure, SameOperandsAndResultType]> {
----------------
xlauko wrote:
```suggestion
def CIR_ByteSwapOp : CIR_Op<"bswap", [Pure, SameOperandsAndResultType]> {
```
https://github.com/llvm/llvm-project/pull/147200
More information about the cfe-commits
mailing list