================ @@ -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); + + let assemblyFormat = [{ + (`left` $isRotateLeft^) : (`right`)? + $input `,` $amount `:` type($result) attr-dict + }]; +} ---------------- xlauko wrote:
```suggestion }]; let extraClassDeclaration = [{ bool isRotateLeft() const { return getRotateLeft(); } bool isRotateRight() const { return !isRotateLeft(); } }]; } ``` https://github.com/llvm/llvm-project/pull/148426 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits