[Mlir-commits] [mlir] [mlir][gpu] Add gpu.rotate operation (PR #142796)

Jakub Kuderski llvmlistbot at llvm.org
Mon Jun 16 08:37:23 PDT 2025


================
@@ -1331,6 +1331,51 @@ void ShuffleOp::build(OpBuilder &builder, OperationState &result, Value value,
         mode);
 }
 
+//===----------------------------------------------------------------------===//
+// RotateOp
+//===----------------------------------------------------------------------===//
+
+void RotateOp::build(OpBuilder &builder, OperationState &result, Value value,
+                     int32_t offset, int32_t width) {
+  build(builder, result, value,
+        builder.create<arith::ConstantOp>(result.location,
+                                          builder.getI32IntegerAttr(offset)),
+        builder.create<arith::ConstantOp>(result.location,
+                                          builder.getI32IntegerAttr(width)));
+}
+
+LogicalResult RotateOp::verify() {
+  llvm::APInt offsetValue;
+  if (auto constOp = getOffset().getDefiningOp<arith::ConstantOp>()) {
+    if (auto intAttr = llvm::dyn_cast<mlir::IntegerAttr>(constOp.getValue())) {
+      offsetValue = intAttr.getValue();
+    } else {
+      return emitOpError() << "offset is not an integer value";
+    }
+  } else {
+    return emitOpError() << "offset is not a constant value";
+  }
+
+  llvm::APInt widthValue;
+  if (auto constOp = getWidth().getDefiningOp<arith::ConstantOp>()) {
+    if (auto intAttr = llvm::dyn_cast<mlir::IntegerAttr>(constOp.getValue())) {
+      widthValue = intAttr.getValue();
+    } else {
+      return emitOpError() << "width is not an integer value";
+    }
+  } else {
+    return emitOpError() << "width is not a constant value";
----------------
kuhar wrote:

Also here

https://github.com/llvm/llvm-project/pull/142796


More information about the Mlir-commits mailing list