Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ def MemRef_GlobalOp : MemRef_Op<"global", [Symbol]> {
MemRefTypeAttr:$type,
OptionalAttr<AnyAttr>:$initial_value,
UnitAttr:$constant,
OptionalAttr<I64Attr>:$alignment);
OptionalAttr<IntValidAlignment<I64Attr>>:$alignment);

let assemblyFormat = [{
($sym_visibility^)?
Expand Down Expand Up @@ -1231,8 +1231,7 @@ def LoadOp : MemRef_Op<"load",
[MemRead]>:$memref,
Variadic<Index>:$indices,
DefaultValuedOptionalAttr<BoolAttr, "false">:$nontemporal,
ConfinedAttr<OptionalAttr<I64Attr>,
[AllAttrOf<[IntPositive, IntPowerOf2]>]>:$alignment);
OptionalAttr<IntValidAlignment<I64Attr>>:$alignment);

let builders = [
OpBuilder<(ins "Value":$memref,
Expand Down Expand Up @@ -1965,8 +1964,7 @@ def MemRef_StoreOp : MemRef_Op<"store",
[MemWrite]>:$memref,
Variadic<Index>:$indices,
DefaultValuedOptionalAttr<BoolAttr, "false">:$nontemporal,
ConfinedAttr<OptionalAttr<I64Attr>,
[AllAttrOf<[IntPositive, IntPowerOf2]>]>:$alignment);
OptionalAttr<IntValidAlignment<I64Attr>>:$alignment);

let builders = [
OpBuilder<(ins "Value":$valueToStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def SPIRV_KHRCooperativeMatrixLoadOp : SPIRV_KhrVendorOp<"CooperativeMatrixLoad"
SPIRV_KHR_CooperativeMatrixLayoutAttr:$matrix_layout,
SPIRV_Integer:$stride,
OptionalAttr<SPIRV_MemoryAccessAttr>:$memory_operand,
OptionalAttr<I32Attr>:$alignment
OptionalAttr<IntValidAlignment<I32Attr>>:$alignment
);

let results = (outs
Expand Down Expand Up @@ -214,7 +214,7 @@ def SPIRV_KHRCooperativeMatrixStoreOp : SPIRV_KhrVendorOp<"CooperativeMatrixStor
SPIRV_KHR_CooperativeMatrixLayoutAttr:$matrix_layout,
SPIRV_Integer:$stride,
OptionalAttr<SPIRV_MemoryAccessAttr>:$memory_operand,
OptionalAttr<I32Attr>:$alignment
OptionalAttr<IntValidAlignment<I32Attr>>:$alignment
);

let results = (outs);
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMemoryOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ def SPIRV_CopyMemoryOp : SPIRV_Op<"CopyMemory", []> {
SPIRV_AnyPtr:$target,
SPIRV_AnyPtr:$source,
OptionalAttr<SPIRV_MemoryAccessAttr>:$memory_access,
OptionalAttr<I32Attr>:$alignment,
OptionalAttr<IntValidAlignment<I32Attr>>:$alignment,
OptionalAttr<SPIRV_MemoryAccessAttr>:$source_memory_access,
OptionalAttr<I32Attr>:$source_alignment
OptionalAttr<IntValidAlignment<I32Attr>>:$source_alignment
);

let results = (outs);
Expand Down
8 changes: 0 additions & 8 deletions mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1549,14 +1549,6 @@ LogicalResult GlobalOp::verify() {
}
}

if (std::optional<uint64_t> alignAttr = getAlignment()) {
uint64_t alignment = *alignAttr;

if (!llvm::isPowerOf2_64(alignment))
return emitError() << "alignment attribute value " << alignment
<< " is not a power of 2";
}

// TODO: verify visibility for declarations.
return success();
}
Expand Down
2 changes: 1 addition & 1 deletion mlir/test/Dialect/MemRef/invalid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ func.func @mismatched_types() {

// -----

// expected-error @+1 {{alignment attribute value 63 is not a power of 2}}
// expected-error @+1 {{'memref.global' op attribute 'alignment' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive and whose value is a power of two > 0}}
memref.global "private" @gv : memref<4xf32> = dense<1.0> { alignment = 63 }

// -----
Expand Down
Loading