20 #include "mlir/Dialect/Bufferization/IR/BufferizationOpsDialect.cpp.inc"
24 constexpr const ::llvm::StringLiteral BufferizationDialect::kWritableAttrName;
28 constexpr const ::llvm::StringLiteral
29 BufferizationDialect::kBufferLayoutAttrName;
39 constexpr const ::llvm::StringLiteral BufferizationDialect::kManualDeallocation;
60 void mlir::bufferization::BufferizationDialect::initialize() {
63 #include "mlir/Dialect/Bufferization/IR/BufferizationOps.cpp.inc"
65 addInterfaces<BufferizationInlinerInterface>();
68 LogicalResult BufferizationDialect::verifyRegionArgAttribute(
69 Operation *op,
unsigned ,
unsigned argIndex,
71 if (attr.
getName() == kWritableAttrName) {
72 if (!llvm::isa<BoolAttr>(attr.
getValue())) {
73 return op->
emitError() <<
"'" << kWritableAttrName
74 <<
"' is expected to be a boolean attribute";
76 if (!isa<FunctionOpInterface>(op))
77 return op->
emitError() <<
"expected '" << kWritableAttrName
78 <<
"' to be used on function-like operations";
79 if (cast<FunctionOpInterface>(op).isExternal())
80 return op->
emitError() <<
"'" << kWritableAttrName
81 <<
"' is invalid on external functions";
84 if (attr.
getName() == kBufferAccessAttrName) {
85 if (!llvm::isa<StringAttr>(attr.
getValue())) {
86 return op->
emitError() <<
"'" << kBufferAccessAttrName
87 <<
"' is expected to be a string attribute";
89 StringRef str = llvm::cast<StringAttr>(attr.
getValue()).getValue();
90 if (str !=
"none" && str !=
"read" && str !=
"write" && str !=
"read-write")
92 <<
"invalid value for '" << kBufferAccessAttrName <<
"'";
93 if (!isa<FunctionOpInterface>(op))
94 return op->
emitError() <<
"expected '" << kBufferAccessAttrName
95 <<
"' to be used on function-like operations";
98 if (attr.
getName() == kBufferLayoutAttrName) {
99 if (!llvm::isa<AffineMapAttr>(attr.
getValue())) {
100 return op->
emitError() <<
"'" << kBufferLayoutAttrName
101 <<
"' is expected to be a affine map attribute";
103 if (!isa<FunctionOpInterface>(op))
104 return op->
emitError() <<
"expected '" << kBufferLayoutAttrName
105 <<
"' to be used on function-like operations";
108 return op->
emitError() <<
"attribute '" << kBufferLayoutAttrName
109 <<
"' not supported as a region arg attribute by the "
110 "bufferization dialect";
114 BufferizationDialect::verifyOperationAttribute(
Operation *op,
116 using bufferization::BufferizableOpInterface;
118 if (attr.
getName() == kManualDeallocation) {
119 if (!mlir::hasEffect<MemoryEffects::Allocate>(op) &&
120 !mlir::hasEffect<MemoryEffects::Free>(op))
122 << kManualDeallocation
123 <<
"' can be used only on ops that have an allocation and/or free "
129 <<
"attribute '" << attr.
getName()
130 <<
"' not supported as an op attribute by the bufferization dialect";
static bool isLegalToInline(InlinerInterface &interface, Region *src, Region *insertRegion, bool shouldCloneInlinedRegion, IRMapping &valueMapping)
Utility to check that all of the operations within 'src' can be inlined.
This is the interface that must be implemented by the dialects of operations to be inlined.
DialectInlinerInterface(Dialect *dialect)
This is a utility class for mapping one set of IR entities to another.
NamedAttribute represents a combination of a name and an Attribute value.
StringAttr getName() const
Return the name of the attribute.
Attribute getValue() const
Return the value of the attribute.
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...
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Include the generated interface declarations.