18 auto memCastOp = cast<MemorySpaceCastOpInterface>(op);
21 Value sourcePtr = memCastOp.getSourcePtr();
22 Value targetPtr = memCastOp.getTargetPtr();
24 if (!sourcePtr || !targetPtr) {
26 <<
"memory space cast op must have valid source and target pointers";
31 <<
"expected source and target types of the same kind";
35 auto sourceType = dyn_cast<PtrLikeTypeInterface>(sourcePtr.
getType());
38 <<
"source type must implement `PtrLikeTypeInterface`, but got: "
42 auto targetType = dyn_cast<PtrLikeTypeInterface>(targetPtr.
getType());
45 <<
"target type must implement `PtrLikeTypeInterface`, but got: "
52 <<
"memory space cast op must have exactly one result";
58 FailureOr<std::optional<SmallVector<Value>>>
61 MemorySpaceCastOpInterface castOp =
62 MemorySpaceCastOpInterface::getIfPromotableCast(operand.
get());
69 operand.
set(castOp.getSourcePtr());
70 return std::optional<SmallVector<Value>>();
73 #include "mlir/Interfaces/MemOpInterfaces.cpp.inc"
IRValueT get() const
Return the current value being used by this operand.
void set(IRValueT newValue)
Set the current value being used by this operand.
This class represents an operand of an operation.
Operation is the basic unit of execution within MLIR.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
unsigned getNumResults()
Return the number of results held by this operation.
TypeID getTypeID()
Return a unique identifier for the concrete type.
This class provides an abstraction over the different types of ranges over Values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
FailureOr< std::optional< SmallVector< Value > > > bubbleDownInPlaceMemorySpaceCastImpl(OpOperand &operand, ValueRange results)
Tries to bubble-down inplace a MemorySpaceCastOpInterface operation referenced by operand.
LogicalResult verifyMemorySpaceCastOpInterface(Operation *op)
Attempt to verify the given memory space cast operation.
Include the generated interface declarations.