18 #include "llvm/ADT/TypeSwitch.h"
27 void PtrDialect::initialize() {
30 #include "mlir/Dialect/Ptr/IR/PtrOps.cpp.inc"
33 #define GET_ATTRDEF_LIST
34 #include "mlir/Dialect/Ptr/IR/PtrOpsAttrs.cpp.inc"
37 #define GET_TYPEDEF_LIST
38 #include "mlir/Dialect/Ptr/IR/PtrOpsTypes.cpp.inc"
54 FromPtrOp fromPtr = *
this;
55 while (fromPtr !=
nullptr) {
59 if (!toPtr || toPtr.getPtr().getType() != fromPtr.getType())
61 Value md = fromPtr.getMetadata();
63 if (!fromPtr.getType().hasPtrMetadata()) {
64 ptrLike = toPtr.getPtr();
68 mdOp && mdOp.getPtr() == toPtr.getPtr())
69 ptrLike = toPtr.getPtr();
72 fromPtr = ptrLike ? ptrLike.
getDefiningOp<FromPtrOp>() :
nullptr;
79 return emitError() <<
"the result type cannot be `!ptr.ptr`";
80 if (
getType().getMemorySpace() != getPtr().
getType().getMemorySpace()) {
82 <<
"expected the input and output to have the same memory space";
112 ToPtrOp toPtr = *
this;
113 while (toPtr !=
nullptr) {
118 ptr = fromPtr.getPtr();
126 if (isa<PtrType>(getPtr().
getType()))
127 return emitError() <<
"the input value cannot be of type `!ptr.ptr`";
128 if (
getType().getMemorySpace() != getPtr().
getType().getMemorySpace()) {
130 <<
"expected the input and output to have the same memory space";
139 llvm::TypeSize TypeOffsetOp::getTypeSize(std::optional<DataLayout> layout) {
150 #include "mlir/Dialect/Ptr/IR/PtrOpsDialect.cpp.inc"
152 #define GET_ATTRDEF_CLASSES
153 #include "mlir/Dialect/Ptr/IR/PtrOpsAttrs.cpp.inc"
155 #include "mlir/Dialect/Ptr/IR/MemorySpaceInterfaces.cpp.inc"
157 #include "mlir/Dialect/Ptr/IR/MemorySpaceAttrInterfaces.cpp.inc"
159 #include "mlir/Dialect/Ptr/IR/PtrOpsEnums.cpp.inc"
161 #define GET_TYPEDEF_CLASSES
162 #include "mlir/Dialect/Ptr/IR/PtrOpsTypes.cpp.inc"
164 #define GET_OP_CLASSES
165 #include "mlir/Dialect/Ptr/IR/PtrOps.cpp.inc"
static Value getBase(Value v)
Looks through known "view-like" ops to find the base memref.
static Type getElementType(Type type)
Determine the element type of type.
Attributes are known-constant values of operations.
The main mechanism for performing data layout queries.
static DataLayout closest(Operation *op)
Returns the layout of the closest parent operation carrying layout info.
llvm::TypeSize getTypeSize(Type t) const
Returns the size of the given type in the current scope.
This class represents a single result from folding an operation.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
Include the generated interface declarations.
detail::constant_int_value_binder m_ConstantInt(IntegerAttr::ValueType *bind_value)
Matches a constant holding a scalar/vector/tensor integer (splat) and writes the integer value to bin...
Type getType(OpFoldResult ofr)
Returns the int type of the integer in ofr.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
LogicalResult verify(Operation *op, bool verifyRecursively=true)
Perform (potentially expensive) checks of invariants, used to detect compiler bugs,...
bool match(Attribute attr)