[clang] [CIR] Add rotate operation (PR #148426)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 14 04:53:59 PDT 2025
================
@@ -2847,6 +2847,37 @@ def ByteSwapOp : CIR_BitOpBase<"byte_swap", CIR_UIntOfWidths<[16, 32, 64]>> {
}];
}
+//===----------------------------------------------------------------------===//
+// RotateOp
+//===----------------------------------------------------------------------===//
+
+def RotateOp : CIR_Op<"rotate", [Pure, SameOperandsAndResultType]> {
+ let summary = "Rotate the bits in the operand integer";
+ let description = [{
+ The `cir.rotate` rotates the bits in `input` by the given amount `amount`.
+ The rotate direction is specified by the `left` and `right` keyword.
+
+ The width of the input integer must be either 8, 16, 32, or 64. `input`,
+ `amount`, and `result` must be of the same type.
+
+ Example:
+
+ ```mlir
+ %r = cir.rotate left %0, %1 -> !u32i
+ %r = cir.rotate right %0, %1 -> !u32i
+ ```
+ }];
+
+ let results = (outs CIR_IntType:$result);
+ let arguments = (ins CIR_IntType:$input, CIR_IntType:$amount,
+ UnitAttr:$isRotateLeft);
----------------
xlauko wrote:
```suggestion
let arguments = (ins
CIR_UIntOfWidths<[8, 16, 32, 64]>:$input,
CIR_IntType:$amount,
UnitAttr:$rotateLeft
);
let results = (outs CIR_IntType:$result);
```
https://github.com/llvm/llvm-project/pull/148426
More information about the cfe-commits
mailing list