Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
28 changes: 20 additions & 8 deletions mlir/include/mlir/Dialect/Ptr/IR/MemorySpaceInterfaces.td
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ def MemorySpaceAttrInterface : AttrInterface<"MemorySpaceAttrInterface"> {
This method checks if it's valid to load a value from the memory space
with a specific type, alignment, and atomic ordering.
If `emitError` is non-null then the method is allowed to emit errors.
Furthermore, if `emitError` is non-null and the result is `false` an
error must have been emitted.
}],
/*returnType=*/ "::mlir::LogicalResult",
/*returnType=*/ "bool",
/*methodName=*/ "isValidLoad",
/*args=*/ (ins "::mlir::Type":$type,
"::mlir::ptr::AtomicOrdering":$ordering,
Expand All @@ -48,8 +50,10 @@ def MemorySpaceAttrInterface : AttrInterface<"MemorySpaceAttrInterface"> {
This method checks if it's valid to store a value in the memory space
with a specific type, alignment, and atomic ordering.
If `emitError` is non-null then the method is allowed to emit errors.
Furthermore, if `emitError` is non-null and the result is `false` an
error must have been emitted.
}],
/*returnType=*/ "::mlir::LogicalResult",
/*returnType=*/ "bool",
/*methodName=*/ "isValidStore",
/*args=*/ (ins "::mlir::Type":$type,
"::mlir::ptr::AtomicOrdering":$ordering,
Expand All @@ -61,8 +65,10 @@ def MemorySpaceAttrInterface : AttrInterface<"MemorySpaceAttrInterface"> {
This method checks if it's valid to perform an atomic operation in the
memory space with a specific type, alignment, and atomic ordering.
If `emitError` is non-null then the method is allowed to emit errors.
Furthermore, if `emitError` is non-null and the result is `false` an
error must have been emitted.
}],
/*returnType=*/ "::mlir::LogicalResult",
/*returnType=*/ "bool",
/*methodName=*/ "isValidAtomicOp",
/*args=*/ (ins "::mlir::ptr::AtomicBinOp":$op,
"::mlir::Type":$type,
Expand All @@ -76,8 +82,10 @@ def MemorySpaceAttrInterface : AttrInterface<"MemorySpaceAttrInterface"> {
in the memory space with a specific type, alignment, and atomic
orderings.
If `emitError` is non-null then the method is allowed to emit errors.
Furthermore, if `emitError` is non-null and the result is `false` an
error must have been emitted.
}],
/*returnType=*/ "::mlir::LogicalResult",
/*returnType=*/ "bool",
/*methodName=*/ "isValidAtomicXchg",
/*args=*/ (ins "::mlir::Type":$type,
"::mlir::ptr::AtomicOrdering":$successOrdering,
Expand All @@ -90,8 +98,10 @@ def MemorySpaceAttrInterface : AttrInterface<"MemorySpaceAttrInterface"> {
This method checks if it's valid to perform an `addrspacecast` op
in the memory space.
If `emitError` is non-null then the method is allowed to emit errors.
Furthermore, if `emitError` is non-null and the result is `false` an
error must have been emitted.
}],
/*returnType=*/ "::mlir::LogicalResult",
/*returnType=*/ "bool",
/*methodName=*/ "isValidAddrSpaceCast",
/*args=*/ (ins "::mlir::Type":$tgt,
"::mlir::Type":$src,
Expand All @@ -101,11 +111,13 @@ def MemorySpaceAttrInterface : AttrInterface<"MemorySpaceAttrInterface"> {
/*desc=*/ [{
This method checks if it's valid to perform a `ptrtoint` or `inttoptr`
op in the memory space.
The first type is expected to be integer-like, while the second must be a
ptr-like type.
The first type is expected to be integer-like, while the second must be
a ptr-like type.
If `emitError` is non-null then the method is allowed to emit errors.
Furthermore, if `emitError` is non-null and the result is `false` an
error must have been emitted.
}],
/*returnType=*/ "::mlir::LogicalResult",
/*returnType=*/ "bool",
/*methodName=*/ "isValidPtrIntCast",
/*args=*/ (ins "::mlir::Type":$intLikeTy,
"::mlir::Type":$ptrLikeTy,
Expand Down
24 changes: 12 additions & 12 deletions mlir/lib/Dialect/Ptr/IR/PtrAttrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,45 @@ constexpr const static unsigned kBitsInByte = 8;
// GenericSpaceAttr
//===----------------------------------------------------------------------===//

LogicalResult GenericSpaceAttr::isValidLoad(
bool GenericSpaceAttr::isValidLoad(
Type type, ptr::AtomicOrdering ordering, IntegerAttr alignment,
function_ref<InFlightDiagnostic()> emitError) const {
return success();
return true;
}

LogicalResult GenericSpaceAttr::isValidStore(
bool GenericSpaceAttr::isValidStore(
Type type, ptr::AtomicOrdering ordering, IntegerAttr alignment,
function_ref<InFlightDiagnostic()> emitError) const {
return success();
return true;
}

LogicalResult GenericSpaceAttr::isValidAtomicOp(
bool GenericSpaceAttr::isValidAtomicOp(
ptr::AtomicBinOp op, Type type, ptr::AtomicOrdering ordering,
IntegerAttr alignment, function_ref<InFlightDiagnostic()> emitError) const {
return success();
return true;
}

LogicalResult GenericSpaceAttr::isValidAtomicXchg(
bool GenericSpaceAttr::isValidAtomicXchg(
Type type, ptr::AtomicOrdering successOrdering,
ptr::AtomicOrdering failureOrdering, IntegerAttr alignment,
function_ref<InFlightDiagnostic()> emitError) const {
return success();
return true;
}

LogicalResult GenericSpaceAttr::isValidAddrSpaceCast(
bool GenericSpaceAttr::isValidAddrSpaceCast(
Type tgt, Type src, function_ref<InFlightDiagnostic()> emitError) const {
// TODO: update this method once the `addrspace_cast` op is added to the
// dialect.
assert(false && "unimplemented, see TODO in the source.");
return failure();
return false;
}

LogicalResult GenericSpaceAttr::isValidPtrIntCast(
bool GenericSpaceAttr::isValidPtrIntCast(
Type intLikeTy, Type ptrLikeTy,
function_ref<InFlightDiagnostic()> emitError) const {
// TODO: update this method once the int-cast ops are added to the dialect.
assert(false && "unimplemented, see TODO in the source.");
return failure();
return false;
}

//===----------------------------------------------------------------------===//
Expand Down
31 changes: 16 additions & 15 deletions mlir/test/lib/Dialect/Test/TestAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,43 +331,44 @@ TestOpAsmAttrInterfaceAttr::getAlias(::llvm::raw_ostream &os) const {
// TestConstMemorySpaceAttr
//===----------------------------------------------------------------------===//

LogicalResult TestConstMemorySpaceAttr::isValidLoad(
bool TestConstMemorySpaceAttr::isValidLoad(
Type type, mlir::ptr::AtomicOrdering ordering, IntegerAttr alignment,
function_ref<InFlightDiagnostic()> emitError) const {
return success();
return true;
}

LogicalResult TestConstMemorySpaceAttr::isValidStore(
bool TestConstMemorySpaceAttr::isValidStore(
Type type, mlir::ptr::AtomicOrdering ordering, IntegerAttr alignment,
function_ref<InFlightDiagnostic()> emitError) const {
return emitError ? (emitError() << "memory space is read-only") : failure();
return emitError ? failed(emitError() << "memory space is read-only") : false;
}

LogicalResult TestConstMemorySpaceAttr::isValidAtomicOp(
bool TestConstMemorySpaceAttr::isValidAtomicOp(
mlir::ptr::AtomicBinOp binOp, Type type, mlir::ptr::AtomicOrdering ordering,
IntegerAttr alignment, function_ref<InFlightDiagnostic()> emitError) const {
return emitError ? (emitError() << "memory space is read-only") : failure();
return emitError ? failed(emitError() << "memory space is read-only") : false;
}

LogicalResult TestConstMemorySpaceAttr::isValidAtomicXchg(
bool TestConstMemorySpaceAttr::isValidAtomicXchg(
Type type, mlir::ptr::AtomicOrdering successOrdering,
mlir::ptr::AtomicOrdering failureOrdering, IntegerAttr alignment,
function_ref<InFlightDiagnostic()> emitError) const {
return emitError ? (emitError() << "memory space is read-only") : failure();
return emitError ? failed(emitError() << "memory space is read-only") : false;
}

LogicalResult TestConstMemorySpaceAttr::isValidAddrSpaceCast(
bool TestConstMemorySpaceAttr::isValidAddrSpaceCast(
Type tgt, Type src, function_ref<InFlightDiagnostic()> emitError) const {
return emitError
? (emitError() << "memory space doesn't allow addrspace casts")
: failure();
return emitError ? failed(emitError()
<< "memory space doesn't allow addrspace casts")
: false;
}

LogicalResult TestConstMemorySpaceAttr::isValidPtrIntCast(
bool TestConstMemorySpaceAttr::isValidPtrIntCast(
Type intLikeTy, Type ptrLikeTy,
function_ref<InFlightDiagnostic()> emitError) const {
return emitError ? (emitError() << "memory space doesn't allow int-ptr casts")
: failure();
return emitError
? failed(emitError() << "memory space doesn't allow int-ptr casts")
: false;
}

//===----------------------------------------------------------------------===//
Expand Down