-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Description
The IntValidAlignment
constraint is currently being used in the vector dialect to verify that the alignment is a positive integer power of two. The memref and SPIR-V dialects also contain operations which denote the alignment of memory operations, however they do not yet use the IntValidAlignment
constraint.
After modifying the memory operations in the memref and SPIR-V dialects to use the IntValidAlignment
constraint, one can also create constructors for these operations which take an instance of llvm::MaybeAlign
as an optional parameter similar to how constructors in the vector dialect are defined here:
llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
Lines 1726 to 1734 in a3eb311
OpBuilder<(ins "VectorType":$resultType, | |
"Value":$base, | |
"ValueRange":$indices, | |
CArg<"bool", "false">:$nontemporal, | |
CArg<"llvm::MaybeAlign", "llvm::MaybeAlign()">:$alignment), [{ | |
return build($_builder, $_state, resultType, base, indices, nontemporal, | |
alignment.has_value() ? $_builder.getI64IntegerAttr(alignment->value()) : | |
nullptr); | |
}]>, |
Finally, one improvement that can be made to all three dialects is to create an interface which returns an llvm::MaybeAlign
as opposed to an std::optional<uint64_t>
. It could be named getMaybeAlign
.