Skip to content

Refactor alignment attributes to use llvm::MaybeAlign and the IntValidAlignment constraint #155677

@amd-eochoalo

Description

@amd-eochoalo

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:

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.

Metadata

Metadata

Assignees

Labels

good first issuehttps://github.com/llvm/llvm-project/contributemlir

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions