[Mlir-commits] [mlir] [mlir][SPIR-V] Add CopyMemorySized support (PR #232190)
Igor Wodiany
llvmlistbot at llvm.org
Tue Oct 20 02:11:14 PDT 2026
================
@@ -548,6 +551,93 @@ LogicalResult CopyMemoryOp::verify() {
MemoryAccessKind::Read);
}
+//===----------------------------------------------------------------------===//
+// spirv.CopyMemorySized
+//===----------------------------------------------------------------------===//
+
+void CopyMemorySizedOp::print(OpAsmPrinter &printer) {
+ printer << ' ' << getTarget() << ", " << getSource() << ", " << getSize();
+
+ SmallVector<StringRef, 4> elidedAttrs;
+ printMemoryAccessAttribute(*this, printer, elidedAttrs);
+ printSourceMemoryAccessAttribute(*this, printer, elidedAttrs,
+ getSourceMemoryAccess(),
+ getSourceAlignment());
+
+ printer.printOptionalAttrDict(
+ (*this)->getDiscardableAttrDictionary().getValue(), elidedAttrs);
+
+ printer << " : " << getTarget().getType() << ", " << getSource().getType()
+ << ", " << getSize().getType();
+}
+
+ParseResult CopyMemorySizedOp::parse(OpAsmParser &parser,
+ OperationState &result) {
+ SmallVector<OpAsmParser::UnresolvedOperand, 3> operandInfo;
+ SMLoc loc = parser.getCurrentLocation();
+ if (parser.parseOperandList(operandInfo, 3) ||
+ parseMemoryAccessAttributes<CopyMemorySizedOp>(parser, result))
+ return failure();
+
+ if (!parser.parseOptionalComma()) {
+ // Parse 2nd memory access attributes.
+ if (parseSourceMemoryAccessAttributes<CopyMemorySizedOp>(parser, result))
+ return failure();
+ }
+
+ SmallVector<Type, 3> operandTypes;
+ if (parser.parseOptionalAttrDict(result.attributes) || parser.parseColon() ||
+ parser.parseTypeList(operandTypes))
+ return failure();
+
+ return parser.resolveOperands(operandInfo, operandTypes, loc,
+ result.operands);
+}
+
+LogicalResult CopyMemorySizedOp::verify() {
+ if (auto constOp = getSize().getDefiningOp<spirv::ConstantOp>()) {
+ if (auto sizeAttr = dyn_cast<IntegerAttr>(constOp.getValue())) {
+ APInt size = sizeAttr.getValue();
+ if (size.isZero())
+ return emitOpError("size must not be a constant zero");
+ if (sizeAttr.getType().isSignedInteger() && size.isNegative())
+ return emitOpError("size must not be a negative signed constant");
+ }
+ }
----------------
IgWod wrote:
We shouldn't verify non-local properties: https://mlir.llvm.org/getting_started/DeveloperGuide/#ir-verifier
https://github.com/llvm/llvm-project/pull/232190
More information about the Mlir-commits
mailing list