| 1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |
| 2 | |* *| |
| 3 | |* Op Definitions *| |
| 4 | |* *| |
| 5 | |* Automatically generated file, do not edit! *| |
| 6 | |* From: BufferizationOps.td *| |
| 7 | |* *| |
| 8 | \*===----------------------------------------------------------------------===*/ |
| 9 | |
| 10 | #ifdef GET_OP_LIST |
| 11 | #undef GET_OP_LIST |
| 12 | |
| 13 | ::mlir::bufferization::AllocTensorOp, |
| 14 | ::mlir::bufferization::CloneOp, |
| 15 | ::mlir::bufferization::DeallocOp, |
| 16 | ::mlir::bufferization::DeallocTensorOp, |
| 17 | ::mlir::bufferization::MaterializeInDestinationOp, |
| 18 | ::mlir::bufferization::ToBufferOp, |
| 19 | ::mlir::bufferization::ToTensorOp |
| 20 | #endif // GET_OP_LIST |
| 21 | |
| 22 | #ifdef GET_OP_CLASSES |
| 23 | #undef GET_OP_CLASSES |
| 24 | |
| 25 | #include "mlir/IR/Builders.h" |
| 26 | #include "mlir/IR/BuiltinAttributes.h" |
| 27 | #include "mlir/IR/BuiltinTypes.h" |
| 28 | #include "mlir/IR/OpImplementation.h" |
| 29 | |
| 30 | |
| 31 | //===----------------------------------------------------------------------===// |
| 32 | // Local Utility Method Definitions |
| 33 | //===----------------------------------------------------------------------===// |
| 34 | |
| 35 | |
| 36 | static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps1( |
| 37 | ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, |
| 38 | unsigned valueIndex) { |
| 39 | if (!((::llvm::isa<::mlir::IndexType>(type)))) { |
| 40 | return op->emitOpError(valueKind) << " #" << valueIndex |
| 41 | << " must be variadic of index, but got " << type; |
| 42 | } |
| 43 | return ::mlir::success(); |
| 44 | } |
| 45 | |
| 46 | static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps2( |
| 47 | ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, |
| 48 | unsigned valueIndex) { |
| 49 | if (!((::llvm::isa<::mlir::bufferization::TensorLikeType>(type)))) { |
| 50 | return op->emitOpError(valueKind) << " #" << valueIndex |
| 51 | << " must be TensorLikeType instance, but got " << type; |
| 52 | } |
| 53 | return ::mlir::success(); |
| 54 | } |
| 55 | |
| 56 | static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps3( |
| 57 | ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, |
| 58 | unsigned valueIndex) { |
| 59 | if (!((::llvm::isa<::mlir::IndexType>(type)))) { |
| 60 | return op->emitOpError(valueKind) << " #" << valueIndex |
| 61 | << " must be index, but got " << type; |
| 62 | } |
| 63 | return ::mlir::success(); |
| 64 | } |
| 65 | |
| 66 | static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps4( |
| 67 | ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, |
| 68 | unsigned valueIndex) { |
| 69 | if (!(((::llvm::isa<::mlir::BaseMemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { |
| 70 | return op->emitOpError(valueKind) << " #" << valueIndex |
| 71 | << " must be ranked or unranked memref of any non-token type values, but got " << type; |
| 72 | } |
| 73 | return ::mlir::success(); |
| 74 | } |
| 75 | |
| 76 | static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps5( |
| 77 | ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, |
| 78 | unsigned valueIndex) { |
| 79 | if (!(((::llvm::isa<::mlir::BaseMemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { |
| 80 | return op->emitOpError(valueKind) << " #" << valueIndex |
| 81 | << " must be variadic of ranked or unranked memref of any non-token type values, but got " << type; |
| 82 | } |
| 83 | return ::mlir::success(); |
| 84 | } |
| 85 | |
| 86 | static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps6( |
| 87 | ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, |
| 88 | unsigned valueIndex) { |
| 89 | if (!((type.isSignlessInteger(1)))) { |
| 90 | return op->emitOpError(valueKind) << " #" << valueIndex |
| 91 | << " must be variadic of 1-bit signless integer, but got " << type; |
| 92 | } |
| 93 | return ::mlir::success(); |
| 94 | } |
| 95 | |
| 96 | static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps7( |
| 97 | ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, |
| 98 | unsigned valueIndex) { |
| 99 | if (!(((::llvm::isa<::mlir::TensorType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { |
| 100 | return op->emitOpError(valueKind) << " #" << valueIndex |
| 101 | << " must be tensor of any non-token type values, but got " << type; |
| 102 | } |
| 103 | return ::mlir::success(); |
| 104 | } |
| 105 | |
| 106 | static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps8( |
| 107 | ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, |
| 108 | unsigned valueIndex) { |
| 109 | if (!(((::llvm::isa<::mlir::ShapedType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { |
| 110 | return op->emitOpError(valueKind) << " #" << valueIndex |
| 111 | << " must be shaped of any non-token type values, but got " << type; |
| 112 | } |
| 113 | return ::mlir::success(); |
| 114 | } |
| 115 | |
| 116 | static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps9( |
| 117 | ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, |
| 118 | unsigned valueIndex) { |
| 119 | if (!((::llvm::isa<::mlir::bufferization::BufferLikeType>(type)))) { |
| 120 | return op->emitOpError(valueKind) << " #" << valueIndex |
| 121 | << " must be BufferLikeType instance, but got " << type; |
| 122 | } |
| 123 | return ::mlir::success(); |
| 124 | } |
| 125 | |
| 126 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_BufferizationOps1( |
| 127 | ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 128 | if (attr && !((true))) |
| 129 | return emitError() << "attribute '" << attrName |
| 130 | << "' failed to satisfy constraint: any attribute" ; |
| 131 | return ::mlir::success(); |
| 132 | } |
| 133 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_BufferizationOps1( |
| 134 | ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { |
| 135 | return __mlir_ods_local_attr_constraint_BufferizationOps1(attr, attrName, [op]() { |
| 136 | return op->emitOpError(); |
| 137 | }); |
| 138 | } |
| 139 | |
| 140 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_BufferizationOps2( |
| 141 | ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 142 | if (attr && !((::llvm::isa<::mlir::UnitAttr>(attr)))) |
| 143 | return emitError() << "attribute '" << attrName |
| 144 | << "' failed to satisfy constraint: unit attribute" ; |
| 145 | return ::mlir::success(); |
| 146 | } |
| 147 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_BufferizationOps2( |
| 148 | ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { |
| 149 | return __mlir_ods_local_attr_constraint_BufferizationOps2(attr, attrName, [op]() { |
| 150 | return op->emitOpError(); |
| 151 | }); |
| 152 | } |
| 153 | namespace mlir::bufferization { |
| 154 | |
| 155 | |
| 156 | //===----------------------------------------------------------------------===// |
| 157 | // ::mlir::bufferization::AllocTensorOp definitions |
| 158 | //===----------------------------------------------------------------------===// |
| 159 | |
| 160 | namespace detail { |
| 161 | |
| 162 | AllocTensorOpGenericAdaptorBase::AllocTensorOpGenericAdaptorBase(AllocTensorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} |
| 163 | |
| 164 | std::pair<unsigned, unsigned> AllocTensorOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { |
| 165 | ::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes; |
| 166 | |
| 167 | unsigned start = 0; |
| 168 | for (unsigned i = 0; i < index; ++i) |
| 169 | start += sizeAttr[i]; |
| 170 | return {start, sizeAttr[index]}; |
| 171 | } |
| 172 | |
| 173 | ::std::optional<::mlir::Attribute> AllocTensorOpGenericAdaptorBase::getMemorySpace() { |
| 174 | auto attr = getMemorySpaceAttr(); |
| 175 | return attr ? ::std::optional<::mlir::Attribute>(attr) : (::std::nullopt); |
| 176 | } |
| 177 | |
| 178 | |
| 179 | } // namespace detail |
| 180 | AllocTensorOpAdaptor::AllocTensorOpAdaptor(AllocTensorOp op) : AllocTensorOpGenericAdaptor(op->getOperands(), op) {} |
| 181 | |
| 182 | ::llvm::LogicalResult AllocTensorOpAdaptor::verify(::mlir::Location loc) { |
| 183 | auto tblgen_memory_space = getProperties().memory_space; (void)tblgen_memory_space; |
| 184 | |
| 185 | if (tblgen_memory_space && !((true))) |
| 186 | return emitError(loc, "'bufferization.alloc_tensor' op attribute 'memory_space' failed to satisfy constraint: any attribute" ); |
| 187 | return ::mlir::success(); |
| 188 | } |
| 189 | |
| 190 | std::pair<unsigned, unsigned> AllocTensorOp::getODSOperandIndexAndLength(unsigned index) { |
| 191 | ::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes; |
| 192 | |
| 193 | unsigned start = 0; |
| 194 | for (unsigned i = 0; i < index; ++i) |
| 195 | start += sizeAttr[i]; |
| 196 | return {start, sizeAttr[index]}; |
| 197 | } |
| 198 | |
| 199 | ::mlir::MutableOperandRange AllocTensorOp::getDynamicSizesMutable() { |
| 200 | auto range = getODSOperandIndexAndLength(0); |
| 201 | auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); |
| 202 | return mutableRange; |
| 203 | } |
| 204 | |
| 205 | ::mlir::MutableOperandRange AllocTensorOp::getCopyMutable() { |
| 206 | auto range = getODSOperandIndexAndLength(1); |
| 207 | auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); |
| 208 | return mutableRange; |
| 209 | } |
| 210 | |
| 211 | ::mlir::MutableOperandRange AllocTensorOp::getSizeHintMutable() { |
| 212 | auto range = getODSOperandIndexAndLength(2); |
| 213 | auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); |
| 214 | return mutableRange; |
| 215 | } |
| 216 | |
| 217 | ::llvm::LogicalResult AllocTensorOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 218 | ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); |
| 219 | if (!dict) { |
| 220 | emitError() << "expected DictionaryAttr to set properties" ; |
| 221 | return ::mlir::failure(); |
| 222 | } |
| 223 | |
| 224 | { |
| 225 | auto attr = dict.get("memory_space" ); |
| 226 | if (::mlir::failed(::mlir::detail::setAttributeProperty( |
| 227 | prop.memory_space, attr, "memory_space" , emitError))) |
| 228 | return ::mlir::failure(); |
| 229 | } |
| 230 | { |
| 231 | |
| 232 | auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, |
| 233 | ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { |
| 234 | return convertFromAttribute(propStorage, propAttr, emitError); |
| 235 | }; |
| 236 | auto attr = dict.get("operandSegmentSizes" ); if (!attr) attr = dict.get("operand_segment_sizes" );; |
| 237 | ; |
| 238 | if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { |
| 239 | return emitError() << "for `operandSegmentSizes`: " ; |
| 240 | }))) |
| 241 | return ::mlir::failure(); |
| 242 | } |
| 243 | return ::mlir::success(); |
| 244 | } |
| 245 | |
| 246 | ::mlir::Attribute AllocTensorOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { |
| 247 | ::mlir::SmallVector<::mlir::NamedAttribute> attrs; |
| 248 | ::mlir::Builder odsBuilder{ctx}; |
| 249 | ::mlir::detail::appendAttributeProperty(attrs, "memory_space" , prop.memory_space); |
| 250 | |
| 251 | { |
| 252 | const auto &propStorage = prop.operandSegmentSizes; |
| 253 | auto attr = [&]() -> ::mlir::Attribute { |
| 254 | return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); |
| 255 | }(); |
| 256 | attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes" , attr)); |
| 257 | } |
| 258 | |
| 259 | if (!attrs.empty()) |
| 260 | return odsBuilder.getDictionaryAttr(attrs); |
| 261 | return {}; |
| 262 | } |
| 263 | |
| 264 | llvm::hash_code AllocTensorOp::computePropertiesHash(const Properties &prop) { |
| 265 | auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { |
| 266 | using ::llvm::hash_value; |
| 267 | return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; |
| 268 | }; |
| 269 | using llvm::hash_value; |
| 270 | return llvm::hash_combine( |
| 271 | llvm::hash_value(prop.memory_space.getAsOpaquePointer()), |
| 272 | hash_operandSegmentSizes_(prop.operandSegmentSizes)); |
| 273 | } |
| 274 | |
| 275 | std::optional<mlir::Attribute> AllocTensorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { |
| 276 | if (name == "memory_space" ) |
| 277 | return prop.memory_space; |
| 278 | if (name == "operand_segment_sizes" || name == "operandSegmentSizes" ) return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); |
| 279 | return std::nullopt; |
| 280 | } |
| 281 | |
| 282 | void AllocTensorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { |
| 283 | if (name == "memory_space" ) { |
| 284 | prop.memory_space = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.memory_space)>>(value); |
| 285 | return; |
| 286 | } |
| 287 | if (name == "operand_segment_sizes" || name == "operandSegmentSizes" ) { |
| 288 | auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); |
| 289 | if (!arrAttr) return; |
| 290 | if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) |
| 291 | return; |
| 292 | llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); |
| 293 | return; |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | void AllocTensorOp::walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor) { |
| 298 | if (prop.memory_space) { |
| 299 | ::mlir::Attribute value = prop.memory_space; |
| 300 | ::mlir::Attribute originalValue = value; |
| 301 | visitor("memory_space" , value); |
| 302 | if (value != originalValue) |
| 303 | setInherentAttr(prop, "memory_space" , value); |
| 304 | } |
| 305 | { |
| 306 | ::mlir::Attribute value = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); |
| 307 | ::mlir::Attribute originalValue = value; |
| 308 | visitor("operandSegmentSizes" , value); |
| 309 | if (value != originalValue) |
| 310 | setInherentAttr(prop, "operandSegmentSizes" , value); |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | ::llvm::LogicalResult AllocTensorOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 315 | { |
| 316 | ::mlir::Attribute attr = attrs.get(getMemorySpaceAttrName(opName)); |
| 317 | if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps1(attr, "memory_space" , emitError))) |
| 318 | return ::mlir::failure(); |
| 319 | } |
| 320 | return ::mlir::success(); |
| 321 | } |
| 322 | |
| 323 | ::llvm::LogicalResult AllocTensorOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { |
| 324 | auto &prop = state.getOrAddProperties<Properties>(); (void)prop; |
| 325 | if (::mlir::failed(reader.readOptionalAttribute(prop.memory_space))) |
| 326 | return ::mlir::failure(); |
| 327 | |
| 328 | if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { |
| 329 | auto &propStorage = prop.operandSegmentSizes; |
| 330 | ::mlir::DenseI32ArrayAttr attr; |
| 331 | if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); |
| 332 | if (attr.size() > static_cast<int64_t>(sizeof(propStorage) / sizeof(int32_t))) { |
| 333 | reader.emitError("size mismatch for operand/result_segment_size" ); |
| 334 | return ::mlir::failure(); |
| 335 | } |
| 336 | ::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin()); |
| 337 | } |
| 338 | |
| 339 | { |
| 340 | auto &propStorage = prop.operandSegmentSizes; |
| 341 | auto readProp = [&]() { |
| 342 | |
| 343 | if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) |
| 344 | return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); |
| 345 | ; |
| 346 | return ::mlir::success(); |
| 347 | }; |
| 348 | if (::mlir::failed(readProp())) |
| 349 | return ::mlir::failure(); |
| 350 | } |
| 351 | return ::mlir::success(); |
| 352 | } |
| 353 | |
| 354 | void AllocTensorOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { |
| 355 | auto &prop = getProperties(); (void)prop; |
| 356 | |
| 357 | writer.writeOptionalAttribute(prop.memory_space); |
| 358 | |
| 359 | if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { |
| 360 | auto &propStorage = prop.operandSegmentSizes; |
| 361 | writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); |
| 362 | } |
| 363 | |
| 364 | { |
| 365 | auto &propStorage = prop.operandSegmentSizes; |
| 366 | |
| 367 | if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) |
| 368 | writer.writeSparseArray(::llvm::ArrayRef(propStorage)); |
| 369 | ; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | ::std::optional<::mlir::Attribute> AllocTensorOp::getMemorySpace() { |
| 374 | auto attr = getMemorySpaceAttr(); |
| 375 | return attr ? ::std::optional<::mlir::Attribute>(attr) : (::std::nullopt); |
| 376 | } |
| 377 | |
| 378 | AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, RankedTensorType type, ValueRange dynamicSizes) { |
| 379 | ::mlir::OperationState __state__(location, getOperationName()); |
| 380 | build(builder, __state__, std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes)); |
| 381 | auto __res__ = builder.create(__state__); |
| 382 | assert((::llvm::isa<AllocTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 383 | return ::llvm::cast<AllocTensorOp>(__res__); |
| 384 | } |
| 385 | |
| 386 | AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, RankedTensorType type, ValueRange dynamicSizes) { |
| 387 | return create(builder, builder.getLoc(), std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes)); |
| 388 | } |
| 389 | |
| 390 | AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, RankedTensorType type, ValueRange dynamicSizes, Value copy) { |
| 391 | ::mlir::OperationState __state__(location, getOperationName()); |
| 392 | build(builder, __state__, std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes), std::forward<decltype(copy)>(copy)); |
| 393 | auto __res__ = builder.create(__state__); |
| 394 | assert((::llvm::isa<AllocTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 395 | return ::llvm::cast<AllocTensorOp>(__res__); |
| 396 | } |
| 397 | |
| 398 | AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, RankedTensorType type, ValueRange dynamicSizes, Value copy) { |
| 399 | return create(builder, builder.getLoc(), std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes), std::forward<decltype(copy)>(copy)); |
| 400 | } |
| 401 | |
| 402 | AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, TensorType type, ValueRange dynamicSizes, Value copy, IntegerAttr memory_space) { |
| 403 | ::mlir::OperationState __state__(location, getOperationName()); |
| 404 | build(builder, __state__, std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes), std::forward<decltype(copy)>(copy), std::forward<decltype(memory_space)>(memory_space)); |
| 405 | auto __res__ = builder.create(__state__); |
| 406 | assert((::llvm::isa<AllocTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 407 | return ::llvm::cast<AllocTensorOp>(__res__); |
| 408 | } |
| 409 | |
| 410 | AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, TensorType type, ValueRange dynamicSizes, Value copy, IntegerAttr memory_space) { |
| 411 | return create(builder, builder.getLoc(), std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes), std::forward<decltype(copy)>(copy), std::forward<decltype(memory_space)>(memory_space)); |
| 412 | } |
| 413 | |
| 414 | AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, TensorLikeType type, ValueRange dynamicSizes, Value copy) { |
| 415 | ::mlir::OperationState __state__(location, getOperationName()); |
| 416 | build(builder, __state__, std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes), std::forward<decltype(copy)>(copy)); |
| 417 | auto __res__ = builder.create(__state__); |
| 418 | assert((::llvm::isa<AllocTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 419 | return ::llvm::cast<AllocTensorOp>(__res__); |
| 420 | } |
| 421 | |
| 422 | AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, TensorLikeType type, ValueRange dynamicSizes, Value copy) { |
| 423 | return create(builder, builder.getLoc(), std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes), std::forward<decltype(copy)>(copy)); |
| 424 | } |
| 425 | |
| 426 | AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, TensorLikeType type, ValueRange dynamicSizes, Value copy, Value size_hint, Attribute memory_space) { |
| 427 | ::mlir::OperationState __state__(location, getOperationName()); |
| 428 | build(builder, __state__, std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes), std::forward<decltype(copy)>(copy), std::forward<decltype(size_hint)>(size_hint), std::forward<decltype(memory_space)>(memory_space)); |
| 429 | auto __res__ = builder.create(__state__); |
| 430 | assert((::llvm::isa<AllocTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 431 | return ::llvm::cast<AllocTensorOp>(__res__); |
| 432 | } |
| 433 | |
| 434 | AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, TensorLikeType type, ValueRange dynamicSizes, Value copy, Value size_hint, Attribute memory_space) { |
| 435 | return create(builder, builder.getLoc(), std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes), std::forward<decltype(copy)>(copy), std::forward<decltype(size_hint)>(size_hint), std::forward<decltype(memory_space)>(memory_space)); |
| 436 | } |
| 437 | |
| 438 | void AllocTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange dynamic_sizes, /*optional*/::mlir::Value copy, /*optional*/::mlir::Value size_hint, /*optional*/::mlir::Attribute memory_space) { |
| 439 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 440 | odsState.addOperands(dynamic_sizes); |
| 441 | if (copy) |
| 442 | odsState.addOperands(copy); |
| 443 | if (size_hint) |
| 444 | odsState.addOperands(size_hint); |
| 445 | ::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(dynamic_sizes.size()), (copy ? 1 : 0), (size_hint ? 1 : 0)}), odsProperties.operandSegmentSizes.begin()); |
| 446 | if (memory_space) { |
| 447 | odsProperties.memory_space = memory_space; |
| 448 | } |
| 449 | odsState.addTypes(result); |
| 450 | } |
| 451 | |
| 452 | AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::ValueRange dynamic_sizes, /*optional*/::mlir::Value copy, /*optional*/::mlir::Value size_hint, /*optional*/::mlir::Attribute memory_space) { |
| 453 | ::mlir::OperationState __state__(location, getOperationName()); |
| 454 | build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(dynamic_sizes)>(dynamic_sizes), std::forward<decltype(copy)>(copy), std::forward<decltype(size_hint)>(size_hint), std::forward<decltype(memory_space)>(memory_space)); |
| 455 | auto __res__ = builder.create(__state__); |
| 456 | assert((::llvm::isa<AllocTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 457 | return ::llvm::cast<AllocTensorOp>(__res__); |
| 458 | } |
| 459 | |
| 460 | AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::ValueRange dynamic_sizes, /*optional*/::mlir::Value copy, /*optional*/::mlir::Value size_hint, /*optional*/::mlir::Attribute memory_space) { |
| 461 | return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(dynamic_sizes)>(dynamic_sizes), std::forward<decltype(copy)>(copy), std::forward<decltype(size_hint)>(size_hint), std::forward<decltype(memory_space)>(memory_space)); |
| 462 | } |
| 463 | |
| 464 | void AllocTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dynamic_sizes, /*optional*/::mlir::Value copy, /*optional*/::mlir::Value size_hint, /*optional*/::mlir::Attribute memory_space) { |
| 465 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 466 | odsState.addOperands(dynamic_sizes); |
| 467 | if (copy) |
| 468 | odsState.addOperands(copy); |
| 469 | if (size_hint) |
| 470 | odsState.addOperands(size_hint); |
| 471 | ::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(dynamic_sizes.size()), (copy ? 1 : 0), (size_hint ? 1 : 0)}), odsProperties.operandSegmentSizes.begin()); |
| 472 | if (memory_space) { |
| 473 | odsProperties.memory_space = memory_space; |
| 474 | } |
| 475 | assert(resultTypes.size() == 1u && "mismatched number of results" ); |
| 476 | odsState.addTypes(resultTypes); |
| 477 | } |
| 478 | |
| 479 | AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dynamic_sizes, /*optional*/::mlir::Value copy, /*optional*/::mlir::Value size_hint, /*optional*/::mlir::Attribute memory_space) { |
| 480 | ::mlir::OperationState __state__(location, getOperationName()); |
| 481 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(dynamic_sizes)>(dynamic_sizes), std::forward<decltype(copy)>(copy), std::forward<decltype(size_hint)>(size_hint), std::forward<decltype(memory_space)>(memory_space)); |
| 482 | auto __res__ = builder.create(__state__); |
| 483 | assert((::llvm::isa<AllocTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 484 | return ::llvm::cast<AllocTensorOp>(__res__); |
| 485 | } |
| 486 | |
| 487 | AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dynamic_sizes, /*optional*/::mlir::Value copy, /*optional*/::mlir::Value size_hint, /*optional*/::mlir::Attribute memory_space) { |
| 488 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(dynamic_sizes)>(dynamic_sizes), std::forward<decltype(copy)>(copy), std::forward<decltype(size_hint)>(size_hint), std::forward<decltype(memory_space)>(memory_space)); |
| 489 | } |
| 490 | |
| 491 | void AllocTensorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 492 | odsState.addOperands(operands); |
| 493 | buildPropertiesAndDiscardableAttributes(odsState, attributes); |
| 494 | assert(resultTypes.size() == 1u && "mismatched number of return types" ); |
| 495 | odsState.addTypes(resultTypes); |
| 496 | } |
| 497 | |
| 498 | AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 499 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH |
| 500 | |
| 501 | ::mlir::OperationState __state__(location, getOperationName()); |
| 502 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 503 | auto __res__ = builder.create(__state__); |
| 504 | assert((::llvm::isa<AllocTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 505 | return ::llvm::cast<AllocTensorOp>(__res__); |
| 506 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP |
| 507 | } |
| 508 | |
| 509 | AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 510 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH |
| 511 | |
| 512 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 513 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP |
| 514 | } |
| 515 | |
| 516 | void AllocTensorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 517 | odsState.addOperands(operands); |
| 518 | odsState.useProperties(const_cast<Properties&>(properties)); |
| 519 | odsState.addAttributes(discardableAttributes); |
| 520 | assert(resultTypes.size() == 1u && "mismatched number of return types" ); |
| 521 | odsState.addTypes(resultTypes); |
| 522 | } |
| 523 | |
| 524 | AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 525 | ::mlir::OperationState __state__(location, getOperationName()); |
| 526 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 527 | auto __res__ = builder.create(__state__); |
| 528 | assert((::llvm::isa<AllocTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 529 | return ::llvm::cast<AllocTensorOp>(__res__); |
| 530 | } |
| 531 | |
| 532 | AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 533 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 534 | } |
| 535 | |
| 536 | ::llvm::LogicalResult AllocTensorOp::verifyInvariantsImpl() { |
| 537 | auto tblgen_memory_space = getProperties().memory_space; (void)tblgen_memory_space; |
| 538 | |
| 539 | if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps1(*this, tblgen_memory_space, "memory_space" ))) |
| 540 | return ::mlir::failure(); |
| 541 | { |
| 542 | unsigned index = 0; (void)index; |
| 543 | auto valueGroup0 = getODSOperands(0); |
| 544 | |
| 545 | for (auto v : valueGroup0) { |
| 546 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps1(*this, v.getType(), "operand" , index++))) |
| 547 | return ::mlir::failure(); |
| 548 | } |
| 549 | auto valueGroup1 = getODSOperands(1); |
| 550 | |
| 551 | if (valueGroup1.size() > 1) { |
| 552 | return emitOpError("operand group starting at #" ) << index |
| 553 | << " requires 0 or 1 element, but found " << valueGroup1.size(); |
| 554 | } |
| 555 | |
| 556 | for (auto v : valueGroup1) { |
| 557 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps2(*this, v.getType(), "operand" , index++))) |
| 558 | return ::mlir::failure(); |
| 559 | } |
| 560 | auto valueGroup2 = getODSOperands(2); |
| 561 | |
| 562 | if (valueGroup2.size() > 1) { |
| 563 | return emitOpError("operand group starting at #" ) << index |
| 564 | << " requires 0 or 1 element, but found " << valueGroup2.size(); |
| 565 | } |
| 566 | |
| 567 | for (auto v : valueGroup2) { |
| 568 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps3(*this, v.getType(), "operand" , index++))) |
| 569 | return ::mlir::failure(); |
| 570 | } |
| 571 | } |
| 572 | { |
| 573 | unsigned index = 0; (void)index; |
| 574 | auto valueGroup0 = getODSResults(0); |
| 575 | |
| 576 | for (auto v : valueGroup0) { |
| 577 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps2(*this, v.getType(), "result" , index++))) |
| 578 | return ::mlir::failure(); |
| 579 | } |
| 580 | } |
| 581 | return ::mlir::success(); |
| 582 | } |
| 583 | |
| 584 | ::llvm::LogicalResult AllocTensorOp::verifyInvariants() { |
| 585 | if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) |
| 586 | return ::mlir::success(); |
| 587 | return ::mlir::failure(); |
| 588 | } |
| 589 | |
| 590 | ::llvm::LogicalResult AllocTensorOp::setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 591 | ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); |
| 592 | if (!dict) { |
| 593 | emitError() << "expected DictionaryAttr to set properties" ; |
| 594 | return ::mlir::failure(); |
| 595 | } |
| 596 | // keep track of used keys in the input dictionary to be able to error out |
| 597 | // if there are some unknown ones. |
| 598 | ::mlir::DenseSet<::mlir::StringAttr> usedKeys; |
| 599 | ::mlir::MLIRContext *ctx = dict.getContext(); |
| 600 | (void)ctx; |
| 601 | { |
| 602 | |
| 603 | auto operandSegmentSizesAttrName = ::mlir::StringAttr::get(ctx, "operandSegmentSizes" ); |
| 604 | usedKeys.insert(operandSegmentSizesAttrName); |
| 605 | auto attr = dict.get(operandSegmentSizesAttrName); |
| 606 | if (!attr) { |
| 607 | emitError() << "expected key entry for operandSegmentSizes in DictionaryAttr to set " |
| 608 | "Properties." ; |
| 609 | return ::mlir::failure(); |
| 610 | } |
| 611 | if (::mlir::failed(::mlir::convertFromAttribute(prop.operandSegmentSizes, attr, [&]() { |
| 612 | return emitError() << "for `operandSegmentSizes`: " ; |
| 613 | }))) |
| 614 | return ::mlir::failure(); |
| 615 | } |
| 616 | { |
| 617 | |
| 618 | auto &propStorage = prop.memory_space; |
| 619 | auto memory_spaceAttrName = ::mlir::StringAttr::get(ctx, "memory_space" ); |
| 620 | auto attr = dict.get(memory_spaceAttrName); |
| 621 | usedKeys.insert(memory_spaceAttrName); |
| 622 | if (attr || /*isRequired=*/false) { |
| 623 | if (!attr) { |
| 624 | emitError() << "expected key entry for memory_space in DictionaryAttr to set " |
| 625 | "Properties." ; |
| 626 | return ::mlir::failure(); |
| 627 | } |
| 628 | auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr); |
| 629 | if (convertedAttr) { |
| 630 | propStorage = convertedAttr; |
| 631 | } else { |
| 632 | emitError() << "Invalid attribute `memory_space` in property conversion: " << attr; |
| 633 | return ::mlir::failure(); |
| 634 | } |
| 635 | } |
| 636 | } |
| 637 | |
| 638 | for (::mlir::NamedAttribute attr : dict) { |
| 639 | if (!usedKeys.contains(attr.getName())) |
| 640 | return emitError() << "unknown key '" << attr.getName() << |
| 641 | "' when parsing properties dictionary" ; |
| 642 | } |
| 643 | return ::mlir::success(); |
| 644 | } |
| 645 | |
| 646 | void AllocTensorOp::buildPropertiesAndDiscardableAttributes(::mlir::OperationState &odsState, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 647 | Properties &properties = odsState.getOrAddProperties<Properties>(); |
| 648 | populateDefaultProperties(odsState.name, properties); |
| 649 | const ::llvm::StringRef inherentNames[] = {"memory_space" , "operandSegmentSizes" , "operand_segment_sizes" }; |
| 650 | ::mlir::detail::splitPropertiesAndDiscardableAttributes( |
| 651 | odsState, attributes, inherentNames, [&](::mlir::DictionaryAttr inherentAttrs) { |
| 652 | return setPropertiesFromAttr(properties, inherentAttrs, |
| 653 | [&]() { return ::mlir::emitError(odsState.location); }); |
| 654 | }); |
| 655 | } |
| 656 | |
| 657 | |
| 658 | } // namespace mlir::bufferization |
| 659 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::AllocTensorOp) |
| 660 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::detail::AllocTensorOpGenericAdaptorBase::Properties) |
| 661 | |
| 662 | namespace mlir::bufferization { |
| 663 | |
| 664 | |
| 665 | //===----------------------------------------------------------------------===// |
| 666 | // ::mlir::bufferization::CloneOp definitions |
| 667 | //===----------------------------------------------------------------------===// |
| 668 | |
| 669 | namespace detail { |
| 670 | |
| 671 | CloneOpGenericAdaptorBase::CloneOpGenericAdaptorBase(CloneOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} |
| 672 | |
| 673 | |
| 674 | } // namespace detail |
| 675 | CloneOpAdaptor::CloneOpAdaptor(CloneOp op) : CloneOpGenericAdaptor(op->getOperands(), op) {} |
| 676 | |
| 677 | ::llvm::LogicalResult CloneOpAdaptor::verify(::mlir::Location loc) { |
| 678 | return ::mlir::success(); |
| 679 | } |
| 680 | |
| 681 | ::llvm::LogicalResult CloneOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 682 | ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); |
| 683 | if (!dict) { |
| 684 | emitError() << "expected DictionaryAttr to set properties" ; |
| 685 | return ::mlir::failure(); |
| 686 | } |
| 687 | return ::mlir::success(); |
| 688 | } |
| 689 | |
| 690 | ::mlir::Attribute CloneOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { |
| 691 | ::mlir::SmallVector<::mlir::NamedAttribute> attrs; |
| 692 | ::mlir::Builder odsBuilder{ctx}; |
| 693 | |
| 694 | if (!attrs.empty()) |
| 695 | return odsBuilder.getDictionaryAttr(attrs); |
| 696 | return {}; |
| 697 | } |
| 698 | |
| 699 | llvm::hash_code CloneOp::computePropertiesHash(const Properties &prop) { |
| 700 | using llvm::hash_value; |
| 701 | return llvm::hash_combine(); |
| 702 | } |
| 703 | |
| 704 | std::optional<mlir::Attribute> CloneOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { |
| 705 | return std::nullopt; |
| 706 | } |
| 707 | |
| 708 | void CloneOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { |
| 709 | } |
| 710 | |
| 711 | void CloneOp::walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor) { |
| 712 | } |
| 713 | |
| 714 | ::llvm::LogicalResult CloneOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 715 | return ::mlir::success(); |
| 716 | } |
| 717 | |
| 718 | void CloneOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value value) { |
| 719 | return build(odsBuilder, odsState, value.getType(), value); |
| 720 | |
| 721 | } |
| 722 | |
| 723 | CloneOp CloneOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value value) { |
| 724 | ::mlir::OperationState __state__(location, getOperationName()); |
| 725 | build(builder, __state__, std::forward<decltype(value)>(value)); |
| 726 | auto __res__ = builder.create(__state__); |
| 727 | assert((::llvm::isa<CloneOp>(__res__)) && "builder didn't return the right type" ); |
| 728 | return ::llvm::cast<CloneOp>(__res__); |
| 729 | } |
| 730 | |
| 731 | CloneOp CloneOp::create(::mlir::ImplicitLocOpBuilder &builder, Value value) { |
| 732 | return create(builder, builder.getLoc(), std::forward<decltype(value)>(value)); |
| 733 | } |
| 734 | |
| 735 | void CloneOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input) { |
| 736 | odsState.addOperands(input); |
| 737 | odsState.addTypes(output); |
| 738 | } |
| 739 | |
| 740 | CloneOp CloneOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input) { |
| 741 | ::mlir::OperationState __state__(location, getOperationName()); |
| 742 | build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input)); |
| 743 | auto __res__ = builder.create(__state__); |
| 744 | assert((::llvm::isa<CloneOp>(__res__)) && "builder didn't return the right type" ); |
| 745 | return ::llvm::cast<CloneOp>(__res__); |
| 746 | } |
| 747 | |
| 748 | CloneOp CloneOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input) { |
| 749 | return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input)); |
| 750 | } |
| 751 | |
| 752 | void CloneOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input) { |
| 753 | odsState.addOperands(input); |
| 754 | assert(resultTypes.size() == 1u && "mismatched number of results" ); |
| 755 | odsState.addTypes(resultTypes); |
| 756 | } |
| 757 | |
| 758 | CloneOp CloneOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input) { |
| 759 | ::mlir::OperationState __state__(location, getOperationName()); |
| 760 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input)); |
| 761 | auto __res__ = builder.create(__state__); |
| 762 | assert((::llvm::isa<CloneOp>(__res__)) && "builder didn't return the right type" ); |
| 763 | return ::llvm::cast<CloneOp>(__res__); |
| 764 | } |
| 765 | |
| 766 | CloneOp CloneOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input) { |
| 767 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input)); |
| 768 | } |
| 769 | |
| 770 | void CloneOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 771 | assert(operands.size() == 1u && "mismatched number of parameters" ); |
| 772 | odsState.addOperands(operands); |
| 773 | odsState.addAttributes(attributes); |
| 774 | assert(resultTypes.size() == 1u && "mismatched number of return types" ); |
| 775 | odsState.addTypes(resultTypes); |
| 776 | } |
| 777 | |
| 778 | CloneOp CloneOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 779 | ::mlir::OperationState __state__(location, getOperationName()); |
| 780 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 781 | auto __res__ = builder.create(__state__); |
| 782 | assert((::llvm::isa<CloneOp>(__res__)) && "builder didn't return the right type" ); |
| 783 | return ::llvm::cast<CloneOp>(__res__); |
| 784 | } |
| 785 | |
| 786 | CloneOp CloneOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 787 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 788 | } |
| 789 | |
| 790 | void CloneOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 791 | assert(operands.size() == 1u && "mismatched number of parameters" ); |
| 792 | odsState.addOperands(operands); |
| 793 | odsState.useProperties(const_cast<Properties&>(properties)); |
| 794 | odsState.addAttributes(discardableAttributes); |
| 795 | assert(resultTypes.size() == 1u && "mismatched number of return types" ); |
| 796 | odsState.addTypes(resultTypes); |
| 797 | } |
| 798 | |
| 799 | CloneOp CloneOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 800 | ::mlir::OperationState __state__(location, getOperationName()); |
| 801 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 802 | auto __res__ = builder.create(__state__); |
| 803 | assert((::llvm::isa<CloneOp>(__res__)) && "builder didn't return the right type" ); |
| 804 | return ::llvm::cast<CloneOp>(__res__); |
| 805 | } |
| 806 | |
| 807 | CloneOp CloneOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 808 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 809 | } |
| 810 | |
| 811 | ::llvm::LogicalResult CloneOp::verifyInvariantsImpl() { |
| 812 | { |
| 813 | unsigned index = 0; (void)index; |
| 814 | auto valueGroup0 = getODSOperands(0); |
| 815 | |
| 816 | for (auto v : valueGroup0) { |
| 817 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps4(*this, v.getType(), "operand" , index++))) |
| 818 | return ::mlir::failure(); |
| 819 | } |
| 820 | } |
| 821 | { |
| 822 | unsigned index = 0; (void)index; |
| 823 | auto valueGroup0 = getODSResults(0); |
| 824 | |
| 825 | for (auto v : valueGroup0) { |
| 826 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps4(*this, v.getType(), "result" , index++))) |
| 827 | return ::mlir::failure(); |
| 828 | } |
| 829 | } |
| 830 | return ::mlir::success(); |
| 831 | } |
| 832 | |
| 833 | ::llvm::LogicalResult CloneOp::verifyInvariants() { |
| 834 | return verifyInvariantsImpl(); |
| 835 | } |
| 836 | |
| 837 | ::mlir::ParseResult CloneOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { |
| 838 | ::mlir::OpAsmParser::UnresolvedOperand inputRawOperand{}; |
| 839 | ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inputOperands(&inputRawOperand, 1); ::llvm::SMLoc inputOperandsLoc; |
| 840 | (void)inputOperandsLoc; |
| 841 | ::mlir::Type inputRawType{}; |
| 842 | ::llvm::ArrayRef<::mlir::Type> inputTypes(&inputRawType, 1); |
| 843 | ::mlir::Type outputRawType{}; |
| 844 | ::llvm::ArrayRef<::mlir::Type> outputTypes(&outputRawType, 1); |
| 845 | |
| 846 | inputOperandsLoc = parser.getCurrentLocation(); |
| 847 | if (parser.parseOperand(inputRawOperand)) |
| 848 | return ::mlir::failure(); |
| 849 | { |
| 850 | auto loc = parser.getCurrentLocation();(void)loc; |
| 851 | if (parser.parseOptionalAttrDict(result.attributes)) |
| 852 | return ::mlir::failure(); |
| 853 | } |
| 854 | if (parser.parseColon()) |
| 855 | return ::mlir::failure(); |
| 856 | |
| 857 | { |
| 858 | ::mlir::BaseMemRefType type; |
| 859 | if (parser.parseCustomTypeWithFallback(type)) |
| 860 | return ::mlir::failure(); |
| 861 | inputRawType = type; |
| 862 | } |
| 863 | if (parser.parseKeyword("to" )) |
| 864 | return ::mlir::failure(); |
| 865 | |
| 866 | { |
| 867 | ::mlir::BaseMemRefType type; |
| 868 | if (parser.parseCustomTypeWithFallback(type)) |
| 869 | return ::mlir::failure(); |
| 870 | outputRawType = type; |
| 871 | } |
| 872 | result.addTypes(outputTypes); |
| 873 | // coverity[ARRAY_VS_SINGLETON] |
| 874 | if (parser.resolveOperands(inputOperands, inputTypes, inputOperandsLoc, result.operands)) |
| 875 | return ::mlir::failure(); |
| 876 | return ::mlir::success(); |
| 877 | } |
| 878 | |
| 879 | LLVM_ATTRIBUTE_MINSIZE void CloneOp::print(::mlir::OpAsmPrinter &_odsPrinter) { |
| 880 | _odsPrinter << ' '; |
| 881 | _odsPrinter << getInput(); |
| 882 | _odsPrinter.printOptionalAttrDict((*this)->getDiscardableAttrDictionary().getValue()); |
| 883 | _odsPrinter << " :" ; |
| 884 | _odsPrinter << ' '; |
| 885 | { |
| 886 | auto type = getInput().getType(); |
| 887 | if (auto validType = ::llvm::dyn_cast<::mlir::BaseMemRefType>(type)) |
| 888 | _odsPrinter.printStrippedAttrOrType(validType); |
| 889 | else |
| 890 | _odsPrinter << type; |
| 891 | } |
| 892 | _odsPrinter << " to" ; |
| 893 | _odsPrinter << ' '; |
| 894 | { |
| 895 | auto type = getOutput().getType(); |
| 896 | if (auto validType = ::llvm::dyn_cast<::mlir::BaseMemRefType>(type)) |
| 897 | _odsPrinter.printStrippedAttrOrType(validType); |
| 898 | else |
| 899 | _odsPrinter << type; |
| 900 | } |
| 901 | } |
| 902 | |
| 903 | void CloneOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { |
| 904 | { |
| 905 | auto valueRange = getODSOperandIndexAndLength(0); |
| 906 | for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { |
| 907 | effects.emplace_back(::mlir::MemoryEffects::Read::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get()); |
| 908 | } |
| 909 | } |
| 910 | { |
| 911 | auto valueRange = getODSResultIndexAndLength(0); |
| 912 | for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { |
| 913 | effects.emplace_back(::mlir::MemoryEffects::Write::get(), getOperation()->getOpResult(idx), 0, false, ::mlir::SideEffects::DefaultResource::get()); |
| 914 | } |
| 915 | } |
| 916 | { |
| 917 | auto valueRange = getODSResultIndexAndLength(0); |
| 918 | for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { |
| 919 | effects.emplace_back(::mlir::MemoryEffects::Allocate::get(), getOperation()->getOpResult(idx), 0, false, ::mlir::SideEffects::DefaultResource::get()); |
| 920 | } |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | |
| 925 | } // namespace mlir::bufferization |
| 926 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::CloneOp) |
| 927 | |
| 928 | namespace mlir::bufferization { |
| 929 | |
| 930 | |
| 931 | //===----------------------------------------------------------------------===// |
| 932 | // ::mlir::bufferization::DeallocOp definitions |
| 933 | //===----------------------------------------------------------------------===// |
| 934 | |
| 935 | namespace detail { |
| 936 | |
| 937 | DeallocOpGenericAdaptorBase::DeallocOpGenericAdaptorBase(DeallocOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} |
| 938 | |
| 939 | std::pair<unsigned, unsigned> DeallocOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { |
| 940 | ::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes; |
| 941 | |
| 942 | unsigned start = 0; |
| 943 | for (unsigned i = 0; i < index; ++i) |
| 944 | start += sizeAttr[i]; |
| 945 | return {start, sizeAttr[index]}; |
| 946 | } |
| 947 | |
| 948 | |
| 949 | } // namespace detail |
| 950 | DeallocOpAdaptor::DeallocOpAdaptor(DeallocOp op) : DeallocOpGenericAdaptor(op->getOperands(), op) {} |
| 951 | |
| 952 | ::llvm::LogicalResult DeallocOpAdaptor::verify(::mlir::Location loc) { |
| 953 | return ::mlir::success(); |
| 954 | } |
| 955 | |
| 956 | std::pair<unsigned, unsigned> DeallocOp::getODSOperandIndexAndLength(unsigned index) { |
| 957 | ::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes; |
| 958 | |
| 959 | unsigned start = 0; |
| 960 | for (unsigned i = 0; i < index; ++i) |
| 961 | start += sizeAttr[i]; |
| 962 | return {start, sizeAttr[index]}; |
| 963 | } |
| 964 | |
| 965 | ::mlir::MutableOperandRange DeallocOp::getMemrefsMutable() { |
| 966 | auto range = getODSOperandIndexAndLength(0); |
| 967 | auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); |
| 968 | return mutableRange; |
| 969 | } |
| 970 | |
| 971 | ::mlir::MutableOperandRange DeallocOp::getConditionsMutable() { |
| 972 | auto range = getODSOperandIndexAndLength(1); |
| 973 | auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); |
| 974 | return mutableRange; |
| 975 | } |
| 976 | |
| 977 | ::mlir::MutableOperandRange DeallocOp::getRetainedMutable() { |
| 978 | auto range = getODSOperandIndexAndLength(2); |
| 979 | auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); |
| 980 | return mutableRange; |
| 981 | } |
| 982 | |
| 983 | std::pair<unsigned, unsigned> DeallocOp::getODSResultIndexAndLength(unsigned index) { |
| 984 | bool isVariadic[] = {true}; |
| 985 | int prevVariadicCount = 0; |
| 986 | for (unsigned i = 0; i < index; ++i) |
| 987 | if (isVariadic[i]) ++prevVariadicCount; |
| 988 | |
| 989 | // Calculate how many dynamic values a static variadic operand corresponds to. |
| 990 | // This assumes all static variadic operands have the same dynamic value count. |
| 991 | int variadicSize = (getOperation()->getNumResults() - 0) / 1; |
| 992 | // `index` passed in as the parameter is the static index which counts each |
| 993 | // operand (variadic or not) as size 1. So here for each previous static variadic |
| 994 | // operand, we need to offset by (variadicSize - 1) to get where the dynamic |
| 995 | // value pack for this static operand starts. |
| 996 | int start = index + (variadicSize - 1) * prevVariadicCount; |
| 997 | int size = isVariadic[index] ? variadicSize : 1; |
| 998 | return {start, size}; |
| 999 | } |
| 1000 | |
| 1001 | ::llvm::LogicalResult DeallocOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 1002 | ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); |
| 1003 | if (!dict) { |
| 1004 | emitError() << "expected DictionaryAttr to set properties" ; |
| 1005 | return ::mlir::failure(); |
| 1006 | } |
| 1007 | { |
| 1008 | |
| 1009 | auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, |
| 1010 | ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { |
| 1011 | return convertFromAttribute(propStorage, propAttr, emitError); |
| 1012 | }; |
| 1013 | auto attr = dict.get("operandSegmentSizes" ); if (!attr) attr = dict.get("operand_segment_sizes" );; |
| 1014 | ; |
| 1015 | if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { |
| 1016 | return emitError() << "for `operandSegmentSizes`: " ; |
| 1017 | }))) |
| 1018 | return ::mlir::failure(); |
| 1019 | } |
| 1020 | return ::mlir::success(); |
| 1021 | } |
| 1022 | |
| 1023 | ::mlir::Attribute DeallocOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { |
| 1024 | ::mlir::SmallVector<::mlir::NamedAttribute> attrs; |
| 1025 | ::mlir::Builder odsBuilder{ctx}; |
| 1026 | |
| 1027 | { |
| 1028 | const auto &propStorage = prop.operandSegmentSizes; |
| 1029 | auto attr = [&]() -> ::mlir::Attribute { |
| 1030 | return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); |
| 1031 | }(); |
| 1032 | attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes" , attr)); |
| 1033 | } |
| 1034 | |
| 1035 | if (!attrs.empty()) |
| 1036 | return odsBuilder.getDictionaryAttr(attrs); |
| 1037 | return {}; |
| 1038 | } |
| 1039 | |
| 1040 | llvm::hash_code DeallocOp::computePropertiesHash(const Properties &prop) { |
| 1041 | auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { |
| 1042 | using ::llvm::hash_value; |
| 1043 | return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; |
| 1044 | }; |
| 1045 | using llvm::hash_value; |
| 1046 | return llvm::hash_combine( |
| 1047 | hash_operandSegmentSizes_(prop.operandSegmentSizes)); |
| 1048 | } |
| 1049 | |
| 1050 | std::optional<mlir::Attribute> DeallocOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { |
| 1051 | if (name == "operand_segment_sizes" || name == "operandSegmentSizes" ) return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); |
| 1052 | return std::nullopt; |
| 1053 | } |
| 1054 | |
| 1055 | void DeallocOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { |
| 1056 | if (name == "operand_segment_sizes" || name == "operandSegmentSizes" ) { |
| 1057 | auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); |
| 1058 | if (!arrAttr) return; |
| 1059 | if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) |
| 1060 | return; |
| 1061 | llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); |
| 1062 | return; |
| 1063 | } |
| 1064 | } |
| 1065 | |
| 1066 | void DeallocOp::walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor) { |
| 1067 | { |
| 1068 | ::mlir::Attribute value = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); |
| 1069 | ::mlir::Attribute originalValue = value; |
| 1070 | visitor("operandSegmentSizes" , value); |
| 1071 | if (value != originalValue) |
| 1072 | setInherentAttr(prop, "operandSegmentSizes" , value); |
| 1073 | } |
| 1074 | } |
| 1075 | |
| 1076 | ::llvm::LogicalResult DeallocOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 1077 | return ::mlir::success(); |
| 1078 | } |
| 1079 | |
| 1080 | ::llvm::LogicalResult DeallocOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { |
| 1081 | auto &prop = state.getOrAddProperties<Properties>(); (void)prop; |
| 1082 | if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { |
| 1083 | auto &propStorage = prop.operandSegmentSizes; |
| 1084 | ::mlir::DenseI32ArrayAttr attr; |
| 1085 | if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); |
| 1086 | if (attr.size() > static_cast<int64_t>(sizeof(propStorage) / sizeof(int32_t))) { |
| 1087 | reader.emitError("size mismatch for operand/result_segment_size" ); |
| 1088 | return ::mlir::failure(); |
| 1089 | } |
| 1090 | ::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin()); |
| 1091 | } |
| 1092 | |
| 1093 | { |
| 1094 | auto &propStorage = prop.operandSegmentSizes; |
| 1095 | auto readProp = [&]() { |
| 1096 | |
| 1097 | if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) |
| 1098 | return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); |
| 1099 | ; |
| 1100 | return ::mlir::success(); |
| 1101 | }; |
| 1102 | if (::mlir::failed(readProp())) |
| 1103 | return ::mlir::failure(); |
| 1104 | } |
| 1105 | return ::mlir::success(); |
| 1106 | } |
| 1107 | |
| 1108 | void DeallocOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { |
| 1109 | auto &prop = getProperties(); (void)prop; |
| 1110 | |
| 1111 | if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { |
| 1112 | auto &propStorage = prop.operandSegmentSizes; |
| 1113 | writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); |
| 1114 | } |
| 1115 | |
| 1116 | { |
| 1117 | auto &propStorage = prop.operandSegmentSizes; |
| 1118 | |
| 1119 | if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) |
| 1120 | writer.writeSparseArray(::llvm::ArrayRef(propStorage)); |
| 1121 | ; |
| 1122 | } |
| 1123 | } |
| 1124 | |
| 1125 | void DeallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange updatedConditions, ::mlir::ValueRange memrefs, ::mlir::ValueRange conditions, ::mlir::ValueRange retained) { |
| 1126 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 1127 | odsState.addOperands(memrefs); |
| 1128 | odsState.addOperands(conditions); |
| 1129 | odsState.addOperands(retained); |
| 1130 | ::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(memrefs.size()), static_cast<int32_t>(conditions.size()), static_cast<int32_t>(retained.size())}), odsProperties.operandSegmentSizes.begin()); |
| 1131 | odsState.addTypes(updatedConditions); |
| 1132 | } |
| 1133 | |
| 1134 | DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange updatedConditions, ::mlir::ValueRange memrefs, ::mlir::ValueRange conditions, ::mlir::ValueRange retained) { |
| 1135 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1136 | build(builder, __state__, std::forward<decltype(updatedConditions)>(updatedConditions), std::forward<decltype(memrefs)>(memrefs), std::forward<decltype(conditions)>(conditions), std::forward<decltype(retained)>(retained)); |
| 1137 | auto __res__ = builder.create(__state__); |
| 1138 | assert((::llvm::isa<DeallocOp>(__res__)) && "builder didn't return the right type" ); |
| 1139 | return ::llvm::cast<DeallocOp>(__res__); |
| 1140 | } |
| 1141 | |
| 1142 | DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange updatedConditions, ::mlir::ValueRange memrefs, ::mlir::ValueRange conditions, ::mlir::ValueRange retained) { |
| 1143 | return create(builder, builder.getLoc(), std::forward<decltype(updatedConditions)>(updatedConditions), std::forward<decltype(memrefs)>(memrefs), std::forward<decltype(conditions)>(conditions), std::forward<decltype(retained)>(retained)); |
| 1144 | } |
| 1145 | |
| 1146 | void DeallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange memrefs, ::mlir::ValueRange conditions, ::mlir::ValueRange retained) { |
| 1147 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 1148 | odsState.addOperands(memrefs); |
| 1149 | odsState.addOperands(conditions); |
| 1150 | odsState.addOperands(retained); |
| 1151 | ::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(memrefs.size()), static_cast<int32_t>(conditions.size()), static_cast<int32_t>(retained.size())}), odsProperties.operandSegmentSizes.begin()); |
| 1152 | |
| 1153 | ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; |
| 1154 | if (::mlir::succeeded(DeallocOp::inferReturnTypes(odsBuilder.getContext(), |
| 1155 | odsState.location, odsState.operands, |
| 1156 | odsState.attributes.getDictionary(odsState.getContext()), |
| 1157 | odsState.getRawProperties(), |
| 1158 | odsState.regions, inferredReturnTypes))) |
| 1159 | odsState.addTypes(inferredReturnTypes); |
| 1160 | else |
| 1161 | ::mlir::detail::reportFatalInferReturnTypesError(odsState); |
| 1162 | |
| 1163 | } |
| 1164 | |
| 1165 | DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange memrefs, ::mlir::ValueRange conditions, ::mlir::ValueRange retained) { |
| 1166 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1167 | build(builder, __state__, std::forward<decltype(memrefs)>(memrefs), std::forward<decltype(conditions)>(conditions), std::forward<decltype(retained)>(retained)); |
| 1168 | auto __res__ = builder.create(__state__); |
| 1169 | assert((::llvm::isa<DeallocOp>(__res__)) && "builder didn't return the right type" ); |
| 1170 | return ::llvm::cast<DeallocOp>(__res__); |
| 1171 | } |
| 1172 | |
| 1173 | DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange memrefs, ::mlir::ValueRange conditions, ::mlir::ValueRange retained) { |
| 1174 | return create(builder, builder.getLoc(), std::forward<decltype(memrefs)>(memrefs), std::forward<decltype(conditions)>(conditions), std::forward<decltype(retained)>(retained)); |
| 1175 | } |
| 1176 | |
| 1177 | void DeallocOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 1178 | odsState.addOperands(operands); |
| 1179 | buildPropertiesAndDiscardableAttributes(odsState, attributes); |
| 1180 | odsState.addTypes(resultTypes); |
| 1181 | } |
| 1182 | |
| 1183 | DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 1184 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH |
| 1185 | |
| 1186 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1187 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 1188 | auto __res__ = builder.create(__state__); |
| 1189 | assert((::llvm::isa<DeallocOp>(__res__)) && "builder didn't return the right type" ); |
| 1190 | return ::llvm::cast<DeallocOp>(__res__); |
| 1191 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP |
| 1192 | } |
| 1193 | |
| 1194 | DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 1195 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH |
| 1196 | |
| 1197 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 1198 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP |
| 1199 | } |
| 1200 | |
| 1201 | void DeallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 1202 | odsState.addOperands(operands); |
| 1203 | buildPropertiesAndDiscardableAttributes(odsState, attributes); |
| 1204 | |
| 1205 | ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; |
| 1206 | if (::mlir::succeeded(DeallocOp::inferReturnTypes(odsBuilder.getContext(), |
| 1207 | odsState.location, operands, |
| 1208 | odsState.attributes.getDictionary(odsState.getContext()), |
| 1209 | odsState.getRawProperties(), |
| 1210 | odsState.regions, inferredReturnTypes))) { |
| 1211 | odsState.addTypes(inferredReturnTypes); |
| 1212 | } else { |
| 1213 | ::llvm::report_fatal_error("Failed to infer result type(s)." ); |
| 1214 | } |
| 1215 | } |
| 1216 | |
| 1217 | DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 1218 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH |
| 1219 | |
| 1220 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1221 | build(builder, __state__, std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 1222 | auto __res__ = builder.create(__state__); |
| 1223 | assert((::llvm::isa<DeallocOp>(__res__)) && "builder didn't return the right type" ); |
| 1224 | return ::llvm::cast<DeallocOp>(__res__); |
| 1225 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP |
| 1226 | } |
| 1227 | |
| 1228 | DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 1229 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH |
| 1230 | |
| 1231 | return create(builder, builder.getLoc(), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 1232 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP |
| 1233 | } |
| 1234 | |
| 1235 | void DeallocOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 1236 | odsState.addOperands(operands); |
| 1237 | odsState.useProperties(const_cast<Properties&>(properties)); |
| 1238 | odsState.addAttributes(discardableAttributes); |
| 1239 | odsState.addTypes(resultTypes); |
| 1240 | } |
| 1241 | |
| 1242 | DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 1243 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1244 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 1245 | auto __res__ = builder.create(__state__); |
| 1246 | assert((::llvm::isa<DeallocOp>(__res__)) && "builder didn't return the right type" ); |
| 1247 | return ::llvm::cast<DeallocOp>(__res__); |
| 1248 | } |
| 1249 | |
| 1250 | DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 1251 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 1252 | } |
| 1253 | |
| 1254 | void DeallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 1255 | odsState.addOperands(operands); |
| 1256 | odsState.useProperties(const_cast<Properties&>(properties)); |
| 1257 | odsState.addAttributes(discardableAttributes); |
| 1258 | |
| 1259 | ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; |
| 1260 | if (::mlir::succeeded(DeallocOp::inferReturnTypes(odsBuilder.getContext(), |
| 1261 | odsState.location, operands, |
| 1262 | odsState.attributes.getDictionary(odsState.getContext()), |
| 1263 | odsState.getRawProperties(), |
| 1264 | odsState.regions, inferredReturnTypes))) { |
| 1265 | odsState.addTypes(inferredReturnTypes); |
| 1266 | } else { |
| 1267 | ::llvm::report_fatal_error("Failed to infer result type(s)." ); |
| 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 1272 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1273 | build(builder, __state__, std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 1274 | auto __res__ = builder.create(__state__); |
| 1275 | assert((::llvm::isa<DeallocOp>(__res__)) && "builder didn't return the right type" ); |
| 1276 | return ::llvm::cast<DeallocOp>(__res__); |
| 1277 | } |
| 1278 | |
| 1279 | DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 1280 | return create(builder, builder.getLoc(), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 1281 | } |
| 1282 | |
| 1283 | ::llvm::LogicalResult DeallocOp::verifyInvariantsImpl() { |
| 1284 | { |
| 1285 | unsigned index = 0; (void)index; |
| 1286 | auto valueGroup0 = getODSOperands(0); |
| 1287 | |
| 1288 | for (auto v : valueGroup0) { |
| 1289 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps5(*this, v.getType(), "operand" , index++))) |
| 1290 | return ::mlir::failure(); |
| 1291 | } |
| 1292 | auto valueGroup1 = getODSOperands(1); |
| 1293 | |
| 1294 | for (auto v : valueGroup1) { |
| 1295 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps6(*this, v.getType(), "operand" , index++))) |
| 1296 | return ::mlir::failure(); |
| 1297 | } |
| 1298 | auto valueGroup2 = getODSOperands(2); |
| 1299 | |
| 1300 | for (auto v : valueGroup2) { |
| 1301 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps5(*this, v.getType(), "operand" , index++))) |
| 1302 | return ::mlir::failure(); |
| 1303 | } |
| 1304 | } |
| 1305 | { |
| 1306 | unsigned index = 0; (void)index; |
| 1307 | auto valueGroup0 = getODSResults(0); |
| 1308 | |
| 1309 | for (auto v : valueGroup0) { |
| 1310 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps6(*this, v.getType(), "result" , index++))) |
| 1311 | return ::mlir::failure(); |
| 1312 | } |
| 1313 | } |
| 1314 | return ::mlir::success(); |
| 1315 | } |
| 1316 | |
| 1317 | ::llvm::LogicalResult DeallocOp::verifyInvariants() { |
| 1318 | if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) |
| 1319 | return ::mlir::success(); |
| 1320 | return ::mlir::failure(); |
| 1321 | } |
| 1322 | |
| 1323 | ::mlir::ParseResult DeallocOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { |
| 1324 | ::mlir::detail::OperandParserStorage<3> odsOperandVectors; |
| 1325 | auto &memrefsOperands = odsOperandVectors[0]; |
| 1326 | ::llvm::SMLoc memrefsOperandsLoc; |
| 1327 | (void)memrefsOperandsLoc; |
| 1328 | ::llvm::SmallVector<::mlir::Type, 1> memrefsTypes; |
| 1329 | auto &conditionsOperands = odsOperandVectors[1]; |
| 1330 | ::llvm::SMLoc conditionsOperandsLoc; |
| 1331 | (void)conditionsOperandsLoc; |
| 1332 | auto &retainedOperands = odsOperandVectors[2]; |
| 1333 | ::llvm::SMLoc retainedOperandsLoc; |
| 1334 | (void)retainedOperandsLoc; |
| 1335 | ::llvm::SmallVector<::mlir::Type, 1> retainedTypes; |
| 1336 | if (::mlir::succeeded(parser.parseOptionalLParen())) { |
| 1337 | |
| 1338 | memrefsOperandsLoc = parser.getCurrentLocation(); |
| 1339 | if (parser.parseOperandList(memrefsOperands)) |
| 1340 | return ::mlir::failure(); |
| 1341 | if (parser.parseColon()) |
| 1342 | return ::mlir::failure(); |
| 1343 | |
| 1344 | if (parser.parseTypeList(memrefsTypes)) |
| 1345 | return ::mlir::failure(); |
| 1346 | if (parser.parseRParen()) |
| 1347 | return ::mlir::failure(); |
| 1348 | if (parser.parseKeyword("if" )) |
| 1349 | return ::mlir::failure(); |
| 1350 | if (parser.parseLParen()) |
| 1351 | return ::mlir::failure(); |
| 1352 | |
| 1353 | conditionsOperandsLoc = parser.getCurrentLocation(); |
| 1354 | if (parser.parseOperandList(conditionsOperands)) |
| 1355 | return ::mlir::failure(); |
| 1356 | if (parser.parseRParen()) |
| 1357 | return ::mlir::failure(); |
| 1358 | } |
| 1359 | if (::mlir::succeeded(parser.parseOptionalKeyword("retain" ))) { |
| 1360 | if (parser.parseLParen()) |
| 1361 | return ::mlir::failure(); |
| 1362 | |
| 1363 | retainedOperandsLoc = parser.getCurrentLocation(); |
| 1364 | if (parser.parseOperandList(retainedOperands)) |
| 1365 | return ::mlir::failure(); |
| 1366 | if (parser.parseColon()) |
| 1367 | return ::mlir::failure(); |
| 1368 | |
| 1369 | if (parser.parseTypeList(retainedTypes)) |
| 1370 | return ::mlir::failure(); |
| 1371 | if (parser.parseRParen()) |
| 1372 | return ::mlir::failure(); |
| 1373 | } |
| 1374 | { |
| 1375 | auto loc = parser.getCurrentLocation();(void)loc; |
| 1376 | if (parser.parseOptionalAttrDict(result.attributes)) |
| 1377 | return ::mlir::failure(); |
| 1378 | } |
| 1379 | ::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(memrefsOperands.size()), static_cast<int32_t>(conditionsOperands.size()), static_cast<int32_t>(retainedOperands.size())}), result.getOrAddProperties<DeallocOp::Properties>().operandSegmentSizes.begin()); |
| 1380 | ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); |
| 1381 | // coverity[ARRAY_VS_SINGLETON] |
| 1382 | if (parser.resolveOperands(memrefsOperands, memrefsTypes, memrefsOperandsLoc, result.operands)) |
| 1383 | return ::mlir::failure(); |
| 1384 | // coverity[ARRAY_VS_SINGLETON] |
| 1385 | if (parser.resolveOperands(conditionsOperands, odsBuildableType0, conditionsOperandsLoc, result.operands)) |
| 1386 | return ::mlir::failure(); |
| 1387 | // coverity[ARRAY_VS_SINGLETON] |
| 1388 | if (parser.resolveOperands(retainedOperands, retainedTypes, retainedOperandsLoc, result.operands)) |
| 1389 | return ::mlir::failure(); |
| 1390 | |
| 1391 | ::llvm::SmallVector<::mlir::Type> inferredReturnTypes; |
| 1392 | if (::mlir::failed(DeallocOp::inferReturnTypes(parser.getContext(), |
| 1393 | result.location, result.operands, |
| 1394 | result.attributes.getDictionary(parser.getContext()), |
| 1395 | result.getRawProperties(), |
| 1396 | result.regions, inferredReturnTypes))) |
| 1397 | return ::mlir::failure(); |
| 1398 | result.addTypes(inferredReturnTypes); |
| 1399 | return ::mlir::success(); |
| 1400 | } |
| 1401 | |
| 1402 | LLVM_ATTRIBUTE_MINSIZE void DeallocOp::print(::mlir::OpAsmPrinter &_odsPrinter) { |
| 1403 | if (!getMemrefs().empty()) { |
| 1404 | _odsPrinter << ' '; |
| 1405 | _odsPrinter << "(" ; |
| 1406 | _odsPrinter << getMemrefs(); |
| 1407 | _odsPrinter << " :" ; |
| 1408 | _odsPrinter << ' '; |
| 1409 | _odsPrinter << getMemrefs().getTypes(); |
| 1410 | _odsPrinter << ")" ; |
| 1411 | _odsPrinter << " if" ; |
| 1412 | _odsPrinter << ' '; |
| 1413 | _odsPrinter << "(" ; |
| 1414 | _odsPrinter << getConditions(); |
| 1415 | _odsPrinter << ")" ; |
| 1416 | } |
| 1417 | if (!getRetained().empty()) { |
| 1418 | _odsPrinter << " retain" ; |
| 1419 | _odsPrinter << ' '; |
| 1420 | _odsPrinter << "(" ; |
| 1421 | _odsPrinter << getRetained(); |
| 1422 | _odsPrinter << " :" ; |
| 1423 | _odsPrinter << ' '; |
| 1424 | _odsPrinter << getRetained().getTypes(); |
| 1425 | _odsPrinter << ")" ; |
| 1426 | } |
| 1427 | _odsPrinter.printOptionalAttrDict((*this)->getDiscardableAttrDictionary().getValue()); |
| 1428 | } |
| 1429 | |
| 1430 | void DeallocOp::buildPropertiesAndDiscardableAttributes(::mlir::OperationState &odsState, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 1431 | Properties &properties = odsState.getOrAddProperties<Properties>(); |
| 1432 | populateDefaultProperties(odsState.name, properties); |
| 1433 | const ::llvm::StringRef inherentNames[] = {"operandSegmentSizes" , "operand_segment_sizes" }; |
| 1434 | ::mlir::detail::splitPropertiesAndDiscardableAttributes( |
| 1435 | odsState, attributes, inherentNames, [&](::mlir::DictionaryAttr inherentAttrs) { |
| 1436 | return setPropertiesFromAttr(properties, inherentAttrs, |
| 1437 | [&]() { return ::mlir::emitError(odsState.location); }); |
| 1438 | }); |
| 1439 | } |
| 1440 | |
| 1441 | |
| 1442 | } // namespace mlir::bufferization |
| 1443 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::DeallocOp) |
| 1444 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::detail::DeallocOpGenericAdaptorBase::Properties) |
| 1445 | |
| 1446 | namespace mlir::bufferization { |
| 1447 | |
| 1448 | |
| 1449 | //===----------------------------------------------------------------------===// |
| 1450 | // ::mlir::bufferization::DeallocTensorOp definitions |
| 1451 | //===----------------------------------------------------------------------===// |
| 1452 | |
| 1453 | namespace detail { |
| 1454 | |
| 1455 | DeallocTensorOpGenericAdaptorBase::DeallocTensorOpGenericAdaptorBase(DeallocTensorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} |
| 1456 | |
| 1457 | |
| 1458 | } // namespace detail |
| 1459 | DeallocTensorOpAdaptor::DeallocTensorOpAdaptor(DeallocTensorOp op) : DeallocTensorOpGenericAdaptor(op->getOperands(), op) {} |
| 1460 | |
| 1461 | ::llvm::LogicalResult DeallocTensorOpAdaptor::verify(::mlir::Location loc) { |
| 1462 | return ::mlir::success(); |
| 1463 | } |
| 1464 | |
| 1465 | ::llvm::LogicalResult DeallocTensorOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 1466 | ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); |
| 1467 | if (!dict) { |
| 1468 | emitError() << "expected DictionaryAttr to set properties" ; |
| 1469 | return ::mlir::failure(); |
| 1470 | } |
| 1471 | return ::mlir::success(); |
| 1472 | } |
| 1473 | |
| 1474 | ::mlir::Attribute DeallocTensorOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { |
| 1475 | ::mlir::SmallVector<::mlir::NamedAttribute> attrs; |
| 1476 | ::mlir::Builder odsBuilder{ctx}; |
| 1477 | |
| 1478 | if (!attrs.empty()) |
| 1479 | return odsBuilder.getDictionaryAttr(attrs); |
| 1480 | return {}; |
| 1481 | } |
| 1482 | |
| 1483 | llvm::hash_code DeallocTensorOp::computePropertiesHash(const Properties &prop) { |
| 1484 | using llvm::hash_value; |
| 1485 | return llvm::hash_combine(); |
| 1486 | } |
| 1487 | |
| 1488 | std::optional<mlir::Attribute> DeallocTensorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { |
| 1489 | return std::nullopt; |
| 1490 | } |
| 1491 | |
| 1492 | void DeallocTensorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { |
| 1493 | } |
| 1494 | |
| 1495 | void DeallocTensorOp::walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor) { |
| 1496 | } |
| 1497 | |
| 1498 | ::llvm::LogicalResult DeallocTensorOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 1499 | return ::mlir::success(); |
| 1500 | } |
| 1501 | |
| 1502 | void DeallocTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tensor) { |
| 1503 | build(odsBuilder, odsState, ::mlir::TypeRange{}, tensor); |
| 1504 | } |
| 1505 | |
| 1506 | DeallocTensorOp DeallocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value tensor) { |
| 1507 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1508 | build(builder, __state__, std::forward<decltype(tensor)>(tensor)); |
| 1509 | auto __res__ = builder.create(__state__); |
| 1510 | assert((::llvm::isa<DeallocTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 1511 | return ::llvm::cast<DeallocTensorOp>(__res__); |
| 1512 | } |
| 1513 | |
| 1514 | DeallocTensorOp DeallocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value tensor) { |
| 1515 | return create(builder, builder.getLoc(), std::forward<decltype(tensor)>(tensor)); |
| 1516 | } |
| 1517 | |
| 1518 | void DeallocTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor) { |
| 1519 | odsState.addOperands(tensor); |
| 1520 | assert(resultTypes.size() == 0u && "mismatched number of results" ); |
| 1521 | odsState.addTypes(resultTypes); |
| 1522 | } |
| 1523 | |
| 1524 | DeallocTensorOp DeallocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value tensor) { |
| 1525 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1526 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(tensor)>(tensor)); |
| 1527 | auto __res__ = builder.create(__state__); |
| 1528 | assert((::llvm::isa<DeallocTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 1529 | return ::llvm::cast<DeallocTensorOp>(__res__); |
| 1530 | } |
| 1531 | |
| 1532 | DeallocTensorOp DeallocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value tensor) { |
| 1533 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(tensor)>(tensor)); |
| 1534 | } |
| 1535 | |
| 1536 | void DeallocTensorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 1537 | assert(operands.size() == 1u && "mismatched number of parameters" ); |
| 1538 | odsState.addOperands(operands); |
| 1539 | odsState.addAttributes(attributes); |
| 1540 | assert(resultTypes.size() == 0u && "mismatched number of return types" ); |
| 1541 | odsState.addTypes(resultTypes); |
| 1542 | } |
| 1543 | |
| 1544 | DeallocTensorOp DeallocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 1545 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1546 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 1547 | auto __res__ = builder.create(__state__); |
| 1548 | assert((::llvm::isa<DeallocTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 1549 | return ::llvm::cast<DeallocTensorOp>(__res__); |
| 1550 | } |
| 1551 | |
| 1552 | DeallocTensorOp DeallocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 1553 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 1554 | } |
| 1555 | |
| 1556 | void DeallocTensorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 1557 | assert(operands.size() == 1u && "mismatched number of parameters" ); |
| 1558 | odsState.addOperands(operands); |
| 1559 | odsState.useProperties(const_cast<Properties&>(properties)); |
| 1560 | odsState.addAttributes(discardableAttributes); |
| 1561 | assert(resultTypes.size() == 0u && "mismatched number of return types" ); |
| 1562 | odsState.addTypes(resultTypes); |
| 1563 | } |
| 1564 | |
| 1565 | DeallocTensorOp DeallocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 1566 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1567 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 1568 | auto __res__ = builder.create(__state__); |
| 1569 | assert((::llvm::isa<DeallocTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 1570 | return ::llvm::cast<DeallocTensorOp>(__res__); |
| 1571 | } |
| 1572 | |
| 1573 | DeallocTensorOp DeallocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 1574 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 1575 | } |
| 1576 | |
| 1577 | ::llvm::LogicalResult DeallocTensorOp::verifyInvariantsImpl() { |
| 1578 | { |
| 1579 | unsigned index = 0; (void)index; |
| 1580 | auto valueGroup0 = getODSOperands(0); |
| 1581 | |
| 1582 | for (auto v : valueGroup0) { |
| 1583 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps7(*this, v.getType(), "operand" , index++))) |
| 1584 | return ::mlir::failure(); |
| 1585 | } |
| 1586 | } |
| 1587 | return ::mlir::success(); |
| 1588 | } |
| 1589 | |
| 1590 | ::llvm::LogicalResult DeallocTensorOp::verifyInvariants() { |
| 1591 | return verifyInvariantsImpl(); |
| 1592 | } |
| 1593 | |
| 1594 | ::mlir::ParseResult DeallocTensorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { |
| 1595 | ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperand{}; |
| 1596 | ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(&tensorRawOperand, 1); ::llvm::SMLoc tensorOperandsLoc; |
| 1597 | (void)tensorOperandsLoc; |
| 1598 | ::mlir::Type tensorRawType{}; |
| 1599 | ::llvm::ArrayRef<::mlir::Type> tensorTypes(&tensorRawType, 1); |
| 1600 | |
| 1601 | tensorOperandsLoc = parser.getCurrentLocation(); |
| 1602 | if (parser.parseOperand(tensorRawOperand)) |
| 1603 | return ::mlir::failure(); |
| 1604 | { |
| 1605 | auto loc = parser.getCurrentLocation();(void)loc; |
| 1606 | if (parser.parseOptionalAttrDict(result.attributes)) |
| 1607 | return ::mlir::failure(); |
| 1608 | } |
| 1609 | if (parser.parseColon()) |
| 1610 | return ::mlir::failure(); |
| 1611 | |
| 1612 | { |
| 1613 | ::mlir::TensorType type; |
| 1614 | if (parser.parseCustomTypeWithFallback(type)) |
| 1615 | return ::mlir::failure(); |
| 1616 | tensorRawType = type; |
| 1617 | } |
| 1618 | // coverity[ARRAY_VS_SINGLETON] |
| 1619 | if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) |
| 1620 | return ::mlir::failure(); |
| 1621 | return ::mlir::success(); |
| 1622 | } |
| 1623 | |
| 1624 | LLVM_ATTRIBUTE_MINSIZE void DeallocTensorOp::print(::mlir::OpAsmPrinter &_odsPrinter) { |
| 1625 | _odsPrinter << ' '; |
| 1626 | _odsPrinter << getTensor(); |
| 1627 | _odsPrinter.printOptionalAttrDict((*this)->getDiscardableAttrDictionary().getValue()); |
| 1628 | _odsPrinter << " :" ; |
| 1629 | _odsPrinter << ' '; |
| 1630 | { |
| 1631 | auto type = getTensor().getType(); |
| 1632 | if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) |
| 1633 | _odsPrinter.printStrippedAttrOrType(validType); |
| 1634 | else |
| 1635 | _odsPrinter << type; |
| 1636 | } |
| 1637 | } |
| 1638 | |
| 1639 | |
| 1640 | } // namespace mlir::bufferization |
| 1641 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::DeallocTensorOp) |
| 1642 | |
| 1643 | namespace mlir::bufferization { |
| 1644 | |
| 1645 | |
| 1646 | //===----------------------------------------------------------------------===// |
| 1647 | // ::mlir::bufferization::MaterializeInDestinationOp definitions |
| 1648 | //===----------------------------------------------------------------------===// |
| 1649 | |
| 1650 | namespace detail { |
| 1651 | |
| 1652 | MaterializeInDestinationOpGenericAdaptorBase::MaterializeInDestinationOpGenericAdaptorBase(MaterializeInDestinationOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} |
| 1653 | |
| 1654 | ::mlir::UnitAttr MaterializeInDestinationOpGenericAdaptorBase::getRestrictAttr() { |
| 1655 | auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().restrict); |
| 1656 | if (!attr) |
| 1657 | attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); |
| 1658 | return attr; |
| 1659 | } |
| 1660 | |
| 1661 | bool MaterializeInDestinationOpGenericAdaptorBase::getRestrict() { |
| 1662 | auto attr = getRestrictAttr(); |
| 1663 | if (!attr) |
| 1664 | return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; |
| 1665 | return attr != nullptr; |
| 1666 | } |
| 1667 | |
| 1668 | ::mlir::UnitAttr MaterializeInDestinationOpGenericAdaptorBase::getWritableAttr() { |
| 1669 | auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().writable); |
| 1670 | if (!attr) |
| 1671 | attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); |
| 1672 | return attr; |
| 1673 | } |
| 1674 | |
| 1675 | bool MaterializeInDestinationOpGenericAdaptorBase::getWritable() { |
| 1676 | auto attr = getWritableAttr(); |
| 1677 | if (!attr) |
| 1678 | return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; |
| 1679 | return attr != nullptr; |
| 1680 | } |
| 1681 | |
| 1682 | |
| 1683 | } // namespace detail |
| 1684 | MaterializeInDestinationOpAdaptor::MaterializeInDestinationOpAdaptor(MaterializeInDestinationOp op) : MaterializeInDestinationOpGenericAdaptor(op->getOperands(), op) {} |
| 1685 | |
| 1686 | ::llvm::LogicalResult MaterializeInDestinationOpAdaptor::verify(::mlir::Location loc) { |
| 1687 | auto tblgen_restrict = getProperties().restrict; (void)tblgen_restrict; |
| 1688 | auto tblgen_writable = getProperties().writable; (void)tblgen_writable; |
| 1689 | |
| 1690 | if (tblgen_restrict && !((::llvm::isa<::mlir::UnitAttr>(tblgen_restrict)))) |
| 1691 | return emitError(loc, "'bufferization.materialize_in_destination' op attribute 'restrict' failed to satisfy constraint: unit attribute" ); |
| 1692 | |
| 1693 | if (tblgen_writable && !((::llvm::isa<::mlir::UnitAttr>(tblgen_writable)))) |
| 1694 | return emitError(loc, "'bufferization.materialize_in_destination' op attribute 'writable' failed to satisfy constraint: unit attribute" ); |
| 1695 | return ::mlir::success(); |
| 1696 | } |
| 1697 | |
| 1698 | std::pair<unsigned, unsigned> MaterializeInDestinationOp::getODSResultIndexAndLength(unsigned index) { |
| 1699 | bool isVariadic[] = {true}; |
| 1700 | int prevVariadicCount = 0; |
| 1701 | for (unsigned i = 0; i < index; ++i) |
| 1702 | if (isVariadic[i]) ++prevVariadicCount; |
| 1703 | |
| 1704 | // Calculate how many dynamic values a static variadic operand corresponds to. |
| 1705 | // This assumes all static variadic operands have the same dynamic value count. |
| 1706 | int variadicSize = (getOperation()->getNumResults() - 0) / 1; |
| 1707 | // `index` passed in as the parameter is the static index which counts each |
| 1708 | // operand (variadic or not) as size 1. So here for each previous static variadic |
| 1709 | // operand, we need to offset by (variadicSize - 1) to get where the dynamic |
| 1710 | // value pack for this static operand starts. |
| 1711 | int start = index + (variadicSize - 1) * prevVariadicCount; |
| 1712 | int size = isVariadic[index] ? variadicSize : 1; |
| 1713 | return {start, size}; |
| 1714 | } |
| 1715 | |
| 1716 | ::llvm::LogicalResult MaterializeInDestinationOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 1717 | ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); |
| 1718 | if (!dict) { |
| 1719 | emitError() << "expected DictionaryAttr to set properties" ; |
| 1720 | return ::mlir::failure(); |
| 1721 | } |
| 1722 | |
| 1723 | { |
| 1724 | auto attr = dict.get("restrict" ); |
| 1725 | if (::mlir::failed(::mlir::detail::setAttributeProperty( |
| 1726 | prop.restrict, attr, "restrict" , emitError))) |
| 1727 | return ::mlir::failure(); |
| 1728 | } |
| 1729 | |
| 1730 | { |
| 1731 | auto attr = dict.get("writable" ); |
| 1732 | if (::mlir::failed(::mlir::detail::setAttributeProperty( |
| 1733 | prop.writable, attr, "writable" , emitError))) |
| 1734 | return ::mlir::failure(); |
| 1735 | } |
| 1736 | return ::mlir::success(); |
| 1737 | } |
| 1738 | |
| 1739 | ::mlir::Attribute MaterializeInDestinationOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { |
| 1740 | ::mlir::SmallVector<::mlir::NamedAttribute> attrs; |
| 1741 | ::mlir::Builder odsBuilder{ctx}; |
| 1742 | ::mlir::detail::appendAttributeProperty(attrs, "restrict" , prop.restrict); |
| 1743 | ::mlir::detail::appendAttributeProperty(attrs, "writable" , prop.writable); |
| 1744 | |
| 1745 | if (!attrs.empty()) |
| 1746 | return odsBuilder.getDictionaryAttr(attrs); |
| 1747 | return {}; |
| 1748 | } |
| 1749 | |
| 1750 | llvm::hash_code MaterializeInDestinationOp::computePropertiesHash(const Properties &prop) { |
| 1751 | using llvm::hash_value; |
| 1752 | return llvm::hash_combine( |
| 1753 | llvm::hash_value(prop.restrict.getAsOpaquePointer()), |
| 1754 | llvm::hash_value(prop.writable.getAsOpaquePointer())); |
| 1755 | } |
| 1756 | |
| 1757 | std::optional<mlir::Attribute> MaterializeInDestinationOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { |
| 1758 | if (name == "restrict" ) |
| 1759 | return prop.restrict; |
| 1760 | |
| 1761 | if (name == "writable" ) |
| 1762 | return prop.writable; |
| 1763 | return std::nullopt; |
| 1764 | } |
| 1765 | |
| 1766 | void MaterializeInDestinationOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { |
| 1767 | if (name == "restrict" ) { |
| 1768 | prop.restrict = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.restrict)>>(value); |
| 1769 | return; |
| 1770 | } |
| 1771 | |
| 1772 | if (name == "writable" ) { |
| 1773 | prop.writable = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.writable)>>(value); |
| 1774 | return; |
| 1775 | } |
| 1776 | } |
| 1777 | |
| 1778 | void MaterializeInDestinationOp::walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor) { |
| 1779 | if (prop.restrict) { |
| 1780 | ::mlir::Attribute value = prop.restrict; |
| 1781 | ::mlir::Attribute originalValue = value; |
| 1782 | visitor("restrict" , value); |
| 1783 | if (value != originalValue) |
| 1784 | setInherentAttr(prop, "restrict" , value); |
| 1785 | } |
| 1786 | |
| 1787 | if (prop.writable) { |
| 1788 | ::mlir::Attribute value = prop.writable; |
| 1789 | ::mlir::Attribute originalValue = value; |
| 1790 | visitor("writable" , value); |
| 1791 | if (value != originalValue) |
| 1792 | setInherentAttr(prop, "writable" , value); |
| 1793 | } |
| 1794 | } |
| 1795 | |
| 1796 | ::llvm::LogicalResult MaterializeInDestinationOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 1797 | { |
| 1798 | ::mlir::Attribute attr = attrs.get(getRestrictAttrName(opName)); |
| 1799 | if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(attr, "restrict" , emitError))) |
| 1800 | return ::mlir::failure(); |
| 1801 | } |
| 1802 | |
| 1803 | { |
| 1804 | ::mlir::Attribute attr = attrs.get(getWritableAttrName(opName)); |
| 1805 | if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(attr, "writable" , emitError))) |
| 1806 | return ::mlir::failure(); |
| 1807 | } |
| 1808 | return ::mlir::success(); |
| 1809 | } |
| 1810 | |
| 1811 | ::llvm::LogicalResult MaterializeInDestinationOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { |
| 1812 | auto &prop = state.getOrAddProperties<Properties>(); (void)prop; |
| 1813 | if (::mlir::failed(reader.readOptionalAttribute(prop.restrict))) |
| 1814 | return ::mlir::failure(); |
| 1815 | |
| 1816 | if (::mlir::failed(reader.readOptionalAttribute(prop.writable))) |
| 1817 | return ::mlir::failure(); |
| 1818 | return ::mlir::success(); |
| 1819 | } |
| 1820 | |
| 1821 | void MaterializeInDestinationOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { |
| 1822 | auto &prop = getProperties(); (void)prop; |
| 1823 | |
| 1824 | writer.writeOptionalAttribute(prop.restrict); |
| 1825 | |
| 1826 | writer.writeOptionalAttribute(prop.writable); |
| 1827 | } |
| 1828 | |
| 1829 | bool MaterializeInDestinationOp::getRestrict() { |
| 1830 | auto attr = getRestrictAttr(); |
| 1831 | if (!attr) |
| 1832 | return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; |
| 1833 | return attr != nullptr; |
| 1834 | } |
| 1835 | |
| 1836 | bool MaterializeInDestinationOp::getWritable() { |
| 1837 | auto attr = getWritableAttr(); |
| 1838 | if (!attr) |
| 1839 | return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; |
| 1840 | return attr != nullptr; |
| 1841 | } |
| 1842 | |
| 1843 | void MaterializeInDestinationOp::setRestrict(bool attrValue) { |
| 1844 | auto &odsProp = getProperties().restrict; |
| 1845 | if (attrValue) |
| 1846 | odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); |
| 1847 | else |
| 1848 | odsProp = nullptr; |
| 1849 | } |
| 1850 | |
| 1851 | void MaterializeInDestinationOp::setWritable(bool attrValue) { |
| 1852 | auto &odsProp = getProperties().writable; |
| 1853 | if (attrValue) |
| 1854 | odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); |
| 1855 | else |
| 1856 | odsProp = nullptr; |
| 1857 | } |
| 1858 | |
| 1859 | MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value source, Value dest) { |
| 1860 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1861 | build(builder, __state__, std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest)); |
| 1862 | auto __res__ = builder.create(__state__); |
| 1863 | assert((::llvm::isa<MaterializeInDestinationOp>(__res__)) && "builder didn't return the right type" ); |
| 1864 | return ::llvm::cast<MaterializeInDestinationOp>(__res__); |
| 1865 | } |
| 1866 | |
| 1867 | MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::ImplicitLocOpBuilder &builder, Value source, Value dest) { |
| 1868 | return create(builder, builder.getLoc(), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest)); |
| 1869 | } |
| 1870 | |
| 1871 | void MaterializeInDestinationOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) { |
| 1872 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 1873 | odsState.addOperands(source); |
| 1874 | odsState.addOperands(dest); |
| 1875 | if (restrict) { |
| 1876 | odsProperties.restrict = restrict; |
| 1877 | } |
| 1878 | if (writable) { |
| 1879 | odsProperties.writable = writable; |
| 1880 | } |
| 1881 | if (result) |
| 1882 | odsState.addTypes(result); |
| 1883 | } |
| 1884 | |
| 1885 | MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) { |
| 1886 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1887 | build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 1888 | auto __res__ = builder.create(__state__); |
| 1889 | assert((::llvm::isa<MaterializeInDestinationOp>(__res__)) && "builder didn't return the right type" ); |
| 1890 | return ::llvm::cast<MaterializeInDestinationOp>(__res__); |
| 1891 | } |
| 1892 | |
| 1893 | MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) { |
| 1894 | return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 1895 | } |
| 1896 | |
| 1897 | void MaterializeInDestinationOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) { |
| 1898 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 1899 | odsState.addOperands(source); |
| 1900 | odsState.addOperands(dest); |
| 1901 | if (restrict) { |
| 1902 | odsProperties.restrict = restrict; |
| 1903 | } |
| 1904 | if (writable) { |
| 1905 | odsProperties.writable = writable; |
| 1906 | } |
| 1907 | odsState.addTypes(resultTypes); |
| 1908 | } |
| 1909 | |
| 1910 | MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) { |
| 1911 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1912 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 1913 | auto __res__ = builder.create(__state__); |
| 1914 | assert((::llvm::isa<MaterializeInDestinationOp>(__res__)) && "builder didn't return the right type" ); |
| 1915 | return ::llvm::cast<MaterializeInDestinationOp>(__res__); |
| 1916 | } |
| 1917 | |
| 1918 | MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) { |
| 1919 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 1920 | } |
| 1921 | |
| 1922 | void MaterializeInDestinationOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/bool restrict, /*optional*/bool writable) { |
| 1923 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 1924 | odsState.addOperands(source); |
| 1925 | odsState.addOperands(dest); |
| 1926 | if (restrict) { |
| 1927 | odsProperties.restrict = ((restrict) ? odsBuilder.getUnitAttr() : nullptr); |
| 1928 | } |
| 1929 | if (writable) { |
| 1930 | odsProperties.writable = ((writable) ? odsBuilder.getUnitAttr() : nullptr); |
| 1931 | } |
| 1932 | if (result) |
| 1933 | odsState.addTypes(result); |
| 1934 | } |
| 1935 | |
| 1936 | MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/bool restrict, /*optional*/bool writable) { |
| 1937 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1938 | build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 1939 | auto __res__ = builder.create(__state__); |
| 1940 | assert((::llvm::isa<MaterializeInDestinationOp>(__res__)) && "builder didn't return the right type" ); |
| 1941 | return ::llvm::cast<MaterializeInDestinationOp>(__res__); |
| 1942 | } |
| 1943 | |
| 1944 | MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/bool restrict, /*optional*/bool writable) { |
| 1945 | return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 1946 | } |
| 1947 | |
| 1948 | void MaterializeInDestinationOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/bool restrict, /*optional*/bool writable) { |
| 1949 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 1950 | odsState.addOperands(source); |
| 1951 | odsState.addOperands(dest); |
| 1952 | if (restrict) { |
| 1953 | odsProperties.restrict = ((restrict) ? odsBuilder.getUnitAttr() : nullptr); |
| 1954 | } |
| 1955 | if (writable) { |
| 1956 | odsProperties.writable = ((writable) ? odsBuilder.getUnitAttr() : nullptr); |
| 1957 | } |
| 1958 | odsState.addTypes(resultTypes); |
| 1959 | } |
| 1960 | |
| 1961 | MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/bool restrict, /*optional*/bool writable) { |
| 1962 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1963 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 1964 | auto __res__ = builder.create(__state__); |
| 1965 | assert((::llvm::isa<MaterializeInDestinationOp>(__res__)) && "builder didn't return the right type" ); |
| 1966 | return ::llvm::cast<MaterializeInDestinationOp>(__res__); |
| 1967 | } |
| 1968 | |
| 1969 | MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/bool restrict, /*optional*/bool writable) { |
| 1970 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 1971 | } |
| 1972 | |
| 1973 | void MaterializeInDestinationOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 1974 | assert(operands.size() == 2u && "mismatched number of parameters" ); |
| 1975 | odsState.addOperands(operands); |
| 1976 | buildPropertiesAndDiscardableAttributes(odsState, attributes); |
| 1977 | odsState.addTypes(resultTypes); |
| 1978 | } |
| 1979 | |
| 1980 | MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 1981 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH |
| 1982 | |
| 1983 | ::mlir::OperationState __state__(location, getOperationName()); |
| 1984 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 1985 | auto __res__ = builder.create(__state__); |
| 1986 | assert((::llvm::isa<MaterializeInDestinationOp>(__res__)) && "builder didn't return the right type" ); |
| 1987 | return ::llvm::cast<MaterializeInDestinationOp>(__res__); |
| 1988 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP |
| 1989 | } |
| 1990 | |
| 1991 | MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 1992 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH |
| 1993 | |
| 1994 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 1995 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP |
| 1996 | } |
| 1997 | |
| 1998 | void MaterializeInDestinationOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 1999 | assert(operands.size() == 2u && "mismatched number of parameters" ); |
| 2000 | odsState.addOperands(operands); |
| 2001 | odsState.useProperties(const_cast<Properties&>(properties)); |
| 2002 | odsState.addAttributes(discardableAttributes); |
| 2003 | odsState.addTypes(resultTypes); |
| 2004 | } |
| 2005 | |
| 2006 | MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 2007 | ::mlir::OperationState __state__(location, getOperationName()); |
| 2008 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 2009 | auto __res__ = builder.create(__state__); |
| 2010 | assert((::llvm::isa<MaterializeInDestinationOp>(__res__)) && "builder didn't return the right type" ); |
| 2011 | return ::llvm::cast<MaterializeInDestinationOp>(__res__); |
| 2012 | } |
| 2013 | |
| 2014 | MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 2015 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 2016 | } |
| 2017 | |
| 2018 | ::llvm::LogicalResult MaterializeInDestinationOp::verifyInvariantsImpl() { |
| 2019 | auto tblgen_restrict = getProperties().restrict; (void)tblgen_restrict; |
| 2020 | auto tblgen_writable = getProperties().writable; (void)tblgen_writable; |
| 2021 | |
| 2022 | if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(*this, tblgen_restrict, "restrict" ))) |
| 2023 | return ::mlir::failure(); |
| 2024 | |
| 2025 | if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(*this, tblgen_writable, "writable" ))) |
| 2026 | return ::mlir::failure(); |
| 2027 | { |
| 2028 | unsigned index = 0; (void)index; |
| 2029 | auto valueGroup0 = getODSOperands(0); |
| 2030 | |
| 2031 | for (auto v : valueGroup0) { |
| 2032 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps7(*this, v.getType(), "operand" , index++))) |
| 2033 | return ::mlir::failure(); |
| 2034 | } |
| 2035 | auto valueGroup1 = getODSOperands(1); |
| 2036 | |
| 2037 | for (auto v : valueGroup1) { |
| 2038 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps8(*this, v.getType(), "operand" , index++))) |
| 2039 | return ::mlir::failure(); |
| 2040 | } |
| 2041 | } |
| 2042 | { |
| 2043 | unsigned index = 0; (void)index; |
| 2044 | auto valueGroup0 = getODSResults(0); |
| 2045 | |
| 2046 | if (valueGroup0.size() > 1) { |
| 2047 | return emitOpError("result group starting at #" ) << index |
| 2048 | << " requires 0 or 1 element, but found " << valueGroup0.size(); |
| 2049 | } |
| 2050 | |
| 2051 | for (auto v : valueGroup0) { |
| 2052 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps7(*this, v.getType(), "result" , index++))) |
| 2053 | return ::mlir::failure(); |
| 2054 | } |
| 2055 | } |
| 2056 | if (!(((getElementTypeOrSelf((*this->getODSOperands(0).begin()))) == (getElementTypeOrSelf((*this->getODSOperands(1).begin()))) && (getElementTypeOrSelf((*this->getODSOperands(1).begin()))) == (getElementTypeOrSelf((*this->getODSOperands(0).begin())))))) |
| 2057 | return emitOpError("failed to verify that all of {source, dest} have same element type" ); |
| 2058 | return ::mlir::success(); |
| 2059 | } |
| 2060 | |
| 2061 | ::llvm::LogicalResult MaterializeInDestinationOp::verifyInvariants() { |
| 2062 | if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) |
| 2063 | return ::mlir::success(); |
| 2064 | return ::mlir::failure(); |
| 2065 | } |
| 2066 | |
| 2067 | ::mlir::ParseResult MaterializeInDestinationOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { |
| 2068 | ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperand{}; |
| 2069 | ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(&sourceRawOperand, 1); ::llvm::SMLoc sourceOperandsLoc; |
| 2070 | (void)sourceOperandsLoc; |
| 2071 | ::mlir::OpAsmParser::UnresolvedOperand destRawOperand{}; |
| 2072 | ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> destOperands(&destRawOperand, 1); ::llvm::SMLoc destOperandsLoc; |
| 2073 | (void)destOperandsLoc; |
| 2074 | ::llvm::ArrayRef<::mlir::Type> allOperandTypes; |
| 2075 | ::llvm::ArrayRef<::mlir::Type> allResultTypes; |
| 2076 | |
| 2077 | sourceOperandsLoc = parser.getCurrentLocation(); |
| 2078 | if (parser.parseOperand(sourceRawOperand)) |
| 2079 | return ::mlir::failure(); |
| 2080 | if (parser.parseKeyword("in" )) |
| 2081 | return ::mlir::failure(); |
| 2082 | if (::mlir::succeeded(parser.parseOptionalKeyword("restrict" ))) { |
| 2083 | result.getOrAddProperties<MaterializeInDestinationOp::Properties>().restrict = parser.getBuilder().getUnitAttr(); } |
| 2084 | if (::mlir::succeeded(parser.parseOptionalKeyword("writable" ))) { |
| 2085 | result.getOrAddProperties<MaterializeInDestinationOp::Properties>().writable = parser.getBuilder().getUnitAttr(); } |
| 2086 | |
| 2087 | destOperandsLoc = parser.getCurrentLocation(); |
| 2088 | if (parser.parseOperand(destRawOperand)) |
| 2089 | return ::mlir::failure(); |
| 2090 | { |
| 2091 | auto loc = parser.getCurrentLocation();(void)loc; |
| 2092 | if (parser.parseOptionalAttrDict(result.attributes)) |
| 2093 | return ::mlir::failure(); |
| 2094 | if (result.attributes.get("restrict" )) |
| 2095 | return parser.emitError(loc, "inherent attribute 'restrict' cannot be parsed from attr-dict when strict properties in assembly format is enabled" ); |
| 2096 | if (result.attributes.get("writable" )) |
| 2097 | return parser.emitError(loc, "inherent attribute 'writable' cannot be parsed from attr-dict when strict properties in assembly format is enabled" ); |
| 2098 | } |
| 2099 | if (parser.parseColon()) |
| 2100 | return ::mlir::failure(); |
| 2101 | |
| 2102 | ::mlir::FunctionType allOperand__allResult_functionType; |
| 2103 | if (parser.parseType(allOperand__allResult_functionType)) |
| 2104 | return ::mlir::failure(); |
| 2105 | allOperandTypes = allOperand__allResult_functionType.getInputs(); |
| 2106 | allResultTypes = allOperand__allResult_functionType.getResults(); |
| 2107 | result.addTypes(allResultTypes); |
| 2108 | // coverity[ARRAY_VS_SINGLETON] |
| 2109 | if (parser.resolveOperands(::llvm::concat<const ::mlir::OpAsmParser::UnresolvedOperand>(sourceOperands, destOperands), allOperandTypes, parser.getNameLoc(), result.operands)) |
| 2110 | return ::mlir::failure(); |
| 2111 | return ::mlir::success(); |
| 2112 | } |
| 2113 | |
| 2114 | LLVM_ATTRIBUTE_MINSIZE void MaterializeInDestinationOp::print(::mlir::OpAsmPrinter &_odsPrinter) { |
| 2115 | _odsPrinter << ' '; |
| 2116 | _odsPrinter << getSource(); |
| 2117 | _odsPrinter << " in" ; |
| 2118 | if ((getRestrictAttr() && getRestrictAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { |
| 2119 | _odsPrinter << " restrict" ; |
| 2120 | } |
| 2121 | if ((getWritableAttr() && getWritableAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { |
| 2122 | _odsPrinter << " writable" ; |
| 2123 | } |
| 2124 | _odsPrinter << ' '; |
| 2125 | _odsPrinter << getDest(); |
| 2126 | _odsPrinter.printOptionalAttrDict((*this)->getDiscardableAttrDictionary().getValue()); |
| 2127 | _odsPrinter << " :" ; |
| 2128 | _odsPrinter << ' '; |
| 2129 | _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); |
| 2130 | } |
| 2131 | |
| 2132 | void MaterializeInDestinationOp::buildPropertiesAndDiscardableAttributes(::mlir::OperationState &odsState, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 2133 | Properties &properties = odsState.getOrAddProperties<Properties>(); |
| 2134 | populateDefaultProperties(odsState.name, properties); |
| 2135 | const ::llvm::StringRef inherentNames[] = {"restrict" , "writable" }; |
| 2136 | ::mlir::detail::splitPropertiesAndDiscardableAttributes( |
| 2137 | odsState, attributes, inherentNames, [&](::mlir::DictionaryAttr inherentAttrs) { |
| 2138 | return setPropertiesFromAttr(properties, inherentAttrs, |
| 2139 | [&]() { return ::mlir::emitError(odsState.location); }); |
| 2140 | }); |
| 2141 | } |
| 2142 | |
| 2143 | |
| 2144 | } // namespace mlir::bufferization |
| 2145 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::MaterializeInDestinationOp) |
| 2146 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::detail::MaterializeInDestinationOpGenericAdaptorBase::Properties) |
| 2147 | |
| 2148 | namespace mlir::bufferization { |
| 2149 | |
| 2150 | |
| 2151 | //===----------------------------------------------------------------------===// |
| 2152 | // ::mlir::bufferization::ToBufferOp definitions |
| 2153 | //===----------------------------------------------------------------------===// |
| 2154 | |
| 2155 | namespace detail { |
| 2156 | |
| 2157 | ToBufferOpGenericAdaptorBase::ToBufferOpGenericAdaptorBase(ToBufferOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} |
| 2158 | |
| 2159 | ::mlir::UnitAttr ToBufferOpGenericAdaptorBase::getReadOnlyAttr() { |
| 2160 | auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().read_only); |
| 2161 | if (!attr) |
| 2162 | attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); |
| 2163 | return attr; |
| 2164 | } |
| 2165 | |
| 2166 | bool ToBufferOpGenericAdaptorBase::getReadOnly() { |
| 2167 | auto attr = getReadOnlyAttr(); |
| 2168 | if (!attr) |
| 2169 | return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; |
| 2170 | return attr != nullptr; |
| 2171 | } |
| 2172 | |
| 2173 | |
| 2174 | } // namespace detail |
| 2175 | ToBufferOpAdaptor::ToBufferOpAdaptor(ToBufferOp op) : ToBufferOpGenericAdaptor(op->getOperands(), op) {} |
| 2176 | |
| 2177 | ::llvm::LogicalResult ToBufferOpAdaptor::verify(::mlir::Location loc) { |
| 2178 | auto tblgen_read_only = getProperties().read_only; (void)tblgen_read_only; |
| 2179 | |
| 2180 | if (tblgen_read_only && !((::llvm::isa<::mlir::UnitAttr>(tblgen_read_only)))) |
| 2181 | return emitError(loc, "'bufferization.to_buffer' op attribute 'read_only' failed to satisfy constraint: unit attribute" ); |
| 2182 | return ::mlir::success(); |
| 2183 | } |
| 2184 | |
| 2185 | ::llvm::LogicalResult ToBufferOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 2186 | ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); |
| 2187 | if (!dict) { |
| 2188 | emitError() << "expected DictionaryAttr to set properties" ; |
| 2189 | return ::mlir::failure(); |
| 2190 | } |
| 2191 | |
| 2192 | { |
| 2193 | auto attr = dict.get("read_only" ); |
| 2194 | if (::mlir::failed(::mlir::detail::setAttributeProperty( |
| 2195 | prop.read_only, attr, "read_only" , emitError))) |
| 2196 | return ::mlir::failure(); |
| 2197 | } |
| 2198 | return ::mlir::success(); |
| 2199 | } |
| 2200 | |
| 2201 | ::mlir::Attribute ToBufferOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { |
| 2202 | ::mlir::SmallVector<::mlir::NamedAttribute> attrs; |
| 2203 | ::mlir::Builder odsBuilder{ctx}; |
| 2204 | ::mlir::detail::appendAttributeProperty(attrs, "read_only" , prop.read_only); |
| 2205 | |
| 2206 | if (!attrs.empty()) |
| 2207 | return odsBuilder.getDictionaryAttr(attrs); |
| 2208 | return {}; |
| 2209 | } |
| 2210 | |
| 2211 | llvm::hash_code ToBufferOp::computePropertiesHash(const Properties &prop) { |
| 2212 | using llvm::hash_value; |
| 2213 | return llvm::hash_combine( |
| 2214 | llvm::hash_value(prop.read_only.getAsOpaquePointer())); |
| 2215 | } |
| 2216 | |
| 2217 | std::optional<mlir::Attribute> ToBufferOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { |
| 2218 | if (name == "read_only" ) |
| 2219 | return prop.read_only; |
| 2220 | return std::nullopt; |
| 2221 | } |
| 2222 | |
| 2223 | void ToBufferOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { |
| 2224 | if (name == "read_only" ) { |
| 2225 | prop.read_only = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.read_only)>>(value); |
| 2226 | return; |
| 2227 | } |
| 2228 | } |
| 2229 | |
| 2230 | void ToBufferOp::walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor) { |
| 2231 | if (prop.read_only) { |
| 2232 | ::mlir::Attribute value = prop.read_only; |
| 2233 | ::mlir::Attribute originalValue = value; |
| 2234 | visitor("read_only" , value); |
| 2235 | if (value != originalValue) |
| 2236 | setInherentAttr(prop, "read_only" , value); |
| 2237 | } |
| 2238 | } |
| 2239 | |
| 2240 | ::llvm::LogicalResult ToBufferOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 2241 | { |
| 2242 | ::mlir::Attribute attr = attrs.get(getReadOnlyAttrName(opName)); |
| 2243 | if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(attr, "read_only" , emitError))) |
| 2244 | return ::mlir::failure(); |
| 2245 | } |
| 2246 | return ::mlir::success(); |
| 2247 | } |
| 2248 | |
| 2249 | ::llvm::LogicalResult ToBufferOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { |
| 2250 | auto &prop = state.getOrAddProperties<Properties>(); (void)prop; |
| 2251 | if (::mlir::failed(reader.readOptionalAttribute(prop.read_only))) |
| 2252 | return ::mlir::failure(); |
| 2253 | return ::mlir::success(); |
| 2254 | } |
| 2255 | |
| 2256 | void ToBufferOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { |
| 2257 | auto &prop = getProperties(); (void)prop; |
| 2258 | |
| 2259 | writer.writeOptionalAttribute(prop.read_only); |
| 2260 | } |
| 2261 | |
| 2262 | bool ToBufferOp::getReadOnly() { |
| 2263 | auto attr = getReadOnlyAttr(); |
| 2264 | if (!attr) |
| 2265 | return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; |
| 2266 | return attr != nullptr; |
| 2267 | } |
| 2268 | |
| 2269 | void ToBufferOp::setReadOnly(bool attrValue) { |
| 2270 | auto &odsProp = getProperties().read_only; |
| 2271 | if (attrValue) |
| 2272 | odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); |
| 2273 | else |
| 2274 | odsProp = nullptr; |
| 2275 | } |
| 2276 | |
| 2277 | void ToBufferOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type buffer, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr read_only) { |
| 2278 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 2279 | odsState.addOperands(tensor); |
| 2280 | if (read_only) { |
| 2281 | odsProperties.read_only = read_only; |
| 2282 | } |
| 2283 | odsState.addTypes(buffer); |
| 2284 | } |
| 2285 | |
| 2286 | ToBufferOp ToBufferOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type buffer, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr read_only) { |
| 2287 | ::mlir::OperationState __state__(location, getOperationName()); |
| 2288 | build(builder, __state__, std::forward<decltype(buffer)>(buffer), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only)); |
| 2289 | auto __res__ = builder.create(__state__); |
| 2290 | assert((::llvm::isa<ToBufferOp>(__res__)) && "builder didn't return the right type" ); |
| 2291 | return ::llvm::cast<ToBufferOp>(__res__); |
| 2292 | } |
| 2293 | |
| 2294 | ToBufferOp ToBufferOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type buffer, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr read_only) { |
| 2295 | return create(builder, builder.getLoc(), std::forward<decltype(buffer)>(buffer), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only)); |
| 2296 | } |
| 2297 | |
| 2298 | void ToBufferOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr read_only) { |
| 2299 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 2300 | odsState.addOperands(tensor); |
| 2301 | if (read_only) { |
| 2302 | odsProperties.read_only = read_only; |
| 2303 | } |
| 2304 | assert(resultTypes.size() == 1u && "mismatched number of results" ); |
| 2305 | odsState.addTypes(resultTypes); |
| 2306 | } |
| 2307 | |
| 2308 | ToBufferOp ToBufferOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr read_only) { |
| 2309 | ::mlir::OperationState __state__(location, getOperationName()); |
| 2310 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only)); |
| 2311 | auto __res__ = builder.create(__state__); |
| 2312 | assert((::llvm::isa<ToBufferOp>(__res__)) && "builder didn't return the right type" ); |
| 2313 | return ::llvm::cast<ToBufferOp>(__res__); |
| 2314 | } |
| 2315 | |
| 2316 | ToBufferOp ToBufferOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr read_only) { |
| 2317 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only)); |
| 2318 | } |
| 2319 | |
| 2320 | void ToBufferOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type buffer, ::mlir::Value tensor, /*optional*/bool read_only) { |
| 2321 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 2322 | odsState.addOperands(tensor); |
| 2323 | if (read_only) { |
| 2324 | odsProperties.read_only = ((read_only) ? odsBuilder.getUnitAttr() : nullptr); |
| 2325 | } |
| 2326 | odsState.addTypes(buffer); |
| 2327 | } |
| 2328 | |
| 2329 | ToBufferOp ToBufferOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type buffer, ::mlir::Value tensor, /*optional*/bool read_only) { |
| 2330 | ::mlir::OperationState __state__(location, getOperationName()); |
| 2331 | build(builder, __state__, std::forward<decltype(buffer)>(buffer), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only)); |
| 2332 | auto __res__ = builder.create(__state__); |
| 2333 | assert((::llvm::isa<ToBufferOp>(__res__)) && "builder didn't return the right type" ); |
| 2334 | return ::llvm::cast<ToBufferOp>(__res__); |
| 2335 | } |
| 2336 | |
| 2337 | ToBufferOp ToBufferOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type buffer, ::mlir::Value tensor, /*optional*/bool read_only) { |
| 2338 | return create(builder, builder.getLoc(), std::forward<decltype(buffer)>(buffer), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only)); |
| 2339 | } |
| 2340 | |
| 2341 | void ToBufferOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/bool read_only) { |
| 2342 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 2343 | odsState.addOperands(tensor); |
| 2344 | if (read_only) { |
| 2345 | odsProperties.read_only = ((read_only) ? odsBuilder.getUnitAttr() : nullptr); |
| 2346 | } |
| 2347 | assert(resultTypes.size() == 1u && "mismatched number of results" ); |
| 2348 | odsState.addTypes(resultTypes); |
| 2349 | } |
| 2350 | |
| 2351 | ToBufferOp ToBufferOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/bool read_only) { |
| 2352 | ::mlir::OperationState __state__(location, getOperationName()); |
| 2353 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only)); |
| 2354 | auto __res__ = builder.create(__state__); |
| 2355 | assert((::llvm::isa<ToBufferOp>(__res__)) && "builder didn't return the right type" ); |
| 2356 | return ::llvm::cast<ToBufferOp>(__res__); |
| 2357 | } |
| 2358 | |
| 2359 | ToBufferOp ToBufferOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/bool read_only) { |
| 2360 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only)); |
| 2361 | } |
| 2362 | |
| 2363 | void ToBufferOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 2364 | assert(operands.size() == 1u && "mismatched number of parameters" ); |
| 2365 | odsState.addOperands(operands); |
| 2366 | buildPropertiesAndDiscardableAttributes(odsState, attributes); |
| 2367 | assert(resultTypes.size() == 1u && "mismatched number of return types" ); |
| 2368 | odsState.addTypes(resultTypes); |
| 2369 | } |
| 2370 | |
| 2371 | ToBufferOp ToBufferOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 2372 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH |
| 2373 | |
| 2374 | ::mlir::OperationState __state__(location, getOperationName()); |
| 2375 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 2376 | auto __res__ = builder.create(__state__); |
| 2377 | assert((::llvm::isa<ToBufferOp>(__res__)) && "builder didn't return the right type" ); |
| 2378 | return ::llvm::cast<ToBufferOp>(__res__); |
| 2379 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP |
| 2380 | } |
| 2381 | |
| 2382 | ToBufferOp ToBufferOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 2383 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH |
| 2384 | |
| 2385 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 2386 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP |
| 2387 | } |
| 2388 | |
| 2389 | void ToBufferOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 2390 | assert(operands.size() == 1u && "mismatched number of parameters" ); |
| 2391 | odsState.addOperands(operands); |
| 2392 | odsState.useProperties(const_cast<Properties&>(properties)); |
| 2393 | odsState.addAttributes(discardableAttributes); |
| 2394 | assert(resultTypes.size() == 1u && "mismatched number of return types" ); |
| 2395 | odsState.addTypes(resultTypes); |
| 2396 | } |
| 2397 | |
| 2398 | ToBufferOp ToBufferOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 2399 | ::mlir::OperationState __state__(location, getOperationName()); |
| 2400 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 2401 | auto __res__ = builder.create(__state__); |
| 2402 | assert((::llvm::isa<ToBufferOp>(__res__)) && "builder didn't return the right type" ); |
| 2403 | return ::llvm::cast<ToBufferOp>(__res__); |
| 2404 | } |
| 2405 | |
| 2406 | ToBufferOp ToBufferOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 2407 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 2408 | } |
| 2409 | |
| 2410 | ::llvm::LogicalResult ToBufferOp::verifyInvariantsImpl() { |
| 2411 | auto tblgen_read_only = getProperties().read_only; (void)tblgen_read_only; |
| 2412 | |
| 2413 | if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(*this, tblgen_read_only, "read_only" ))) |
| 2414 | return ::mlir::failure(); |
| 2415 | { |
| 2416 | unsigned index = 0; (void)index; |
| 2417 | auto valueGroup0 = getODSOperands(0); |
| 2418 | |
| 2419 | for (auto v : valueGroup0) { |
| 2420 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps2(*this, v.getType(), "operand" , index++))) |
| 2421 | return ::mlir::failure(); |
| 2422 | } |
| 2423 | } |
| 2424 | { |
| 2425 | unsigned index = 0; (void)index; |
| 2426 | auto valueGroup0 = getODSResults(0); |
| 2427 | |
| 2428 | for (auto v : valueGroup0) { |
| 2429 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps9(*this, v.getType(), "result" , index++))) |
| 2430 | return ::mlir::failure(); |
| 2431 | } |
| 2432 | } |
| 2433 | if (!((::mlir::bufferization::detail::typesMatchAfterBufferization((*this->getOperation()), (*this->getODSOperands(0).begin()), (*this->getODSResults(0).begin()))))) |
| 2434 | return emitOpError("failed to verify that specified tensor and buffer types match" ); |
| 2435 | return ::mlir::success(); |
| 2436 | } |
| 2437 | |
| 2438 | ::llvm::LogicalResult ToBufferOp::verifyInvariants() { |
| 2439 | return verifyInvariantsImpl(); |
| 2440 | } |
| 2441 | |
| 2442 | ::mlir::ParseResult ToBufferOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { |
| 2443 | ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperand{}; |
| 2444 | ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(&tensorRawOperand, 1); ::llvm::SMLoc tensorOperandsLoc; |
| 2445 | (void)tensorOperandsLoc; |
| 2446 | ::mlir::Type tensorRawType{}; |
| 2447 | ::llvm::ArrayRef<::mlir::Type> tensorTypes(&tensorRawType, 1); |
| 2448 | ::mlir::Type bufferRawType{}; |
| 2449 | ::llvm::ArrayRef<::mlir::Type> bufferTypes(&bufferRawType, 1); |
| 2450 | |
| 2451 | tensorOperandsLoc = parser.getCurrentLocation(); |
| 2452 | if (parser.parseOperand(tensorRawOperand)) |
| 2453 | return ::mlir::failure(); |
| 2454 | if (::mlir::succeeded(parser.parseOptionalKeyword("read_only" ))) { |
| 2455 | result.getOrAddProperties<ToBufferOp::Properties>().read_only = parser.getBuilder().getUnitAttr(); } |
| 2456 | { |
| 2457 | auto loc = parser.getCurrentLocation();(void)loc; |
| 2458 | if (parser.parseOptionalAttrDict(result.attributes)) |
| 2459 | return ::mlir::failure(); |
| 2460 | if (result.attributes.get("read_only" )) |
| 2461 | return parser.emitError(loc, "inherent attribute 'read_only' cannot be parsed from attr-dict when strict properties in assembly format is enabled" ); |
| 2462 | } |
| 2463 | if (parser.parseColon()) |
| 2464 | return ::mlir::failure(); |
| 2465 | |
| 2466 | { |
| 2467 | ::mlir::bufferization::TensorLikeType type; |
| 2468 | if (parser.parseCustomTypeWithFallback(type)) |
| 2469 | return ::mlir::failure(); |
| 2470 | tensorRawType = type; |
| 2471 | } |
| 2472 | if (parser.parseKeyword("to" )) |
| 2473 | return ::mlir::failure(); |
| 2474 | |
| 2475 | { |
| 2476 | ::mlir::bufferization::BufferLikeType type; |
| 2477 | if (parser.parseCustomTypeWithFallback(type)) |
| 2478 | return ::mlir::failure(); |
| 2479 | bufferRawType = type; |
| 2480 | } |
| 2481 | result.addTypes(bufferTypes); |
| 2482 | // coverity[ARRAY_VS_SINGLETON] |
| 2483 | if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) |
| 2484 | return ::mlir::failure(); |
| 2485 | return ::mlir::success(); |
| 2486 | } |
| 2487 | |
| 2488 | LLVM_ATTRIBUTE_MINSIZE void ToBufferOp::print(::mlir::OpAsmPrinter &_odsPrinter) { |
| 2489 | _odsPrinter << ' '; |
| 2490 | _odsPrinter << getTensor(); |
| 2491 | if ((getReadOnlyAttr() && getReadOnlyAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { |
| 2492 | _odsPrinter << " read_only" ; |
| 2493 | } |
| 2494 | _odsPrinter.printOptionalAttrDict((*this)->getDiscardableAttrDictionary().getValue()); |
| 2495 | _odsPrinter << " :" ; |
| 2496 | _odsPrinter << ' '; |
| 2497 | { |
| 2498 | auto type = getTensor().getType(); |
| 2499 | if (auto validType = ::llvm::dyn_cast<::mlir::bufferization::TensorLikeType>(type)) |
| 2500 | _odsPrinter.printStrippedAttrOrType(validType); |
| 2501 | else |
| 2502 | _odsPrinter << type; |
| 2503 | } |
| 2504 | _odsPrinter << " to" ; |
| 2505 | _odsPrinter << ' '; |
| 2506 | { |
| 2507 | auto type = getBuffer().getType(); |
| 2508 | if (auto validType = ::llvm::dyn_cast<::mlir::bufferization::BufferLikeType>(type)) |
| 2509 | _odsPrinter.printStrippedAttrOrType(validType); |
| 2510 | else |
| 2511 | _odsPrinter << type; |
| 2512 | } |
| 2513 | } |
| 2514 | |
| 2515 | void ToBufferOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { |
| 2516 | } |
| 2517 | |
| 2518 | void ToBufferOp::buildPropertiesAndDiscardableAttributes(::mlir::OperationState &odsState, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 2519 | Properties &properties = odsState.getOrAddProperties<Properties>(); |
| 2520 | populateDefaultProperties(odsState.name, properties); |
| 2521 | const ::llvm::StringRef inherentNames[] = {"read_only" }; |
| 2522 | ::mlir::detail::splitPropertiesAndDiscardableAttributes( |
| 2523 | odsState, attributes, inherentNames, [&](::mlir::DictionaryAttr inherentAttrs) { |
| 2524 | return setPropertiesFromAttr(properties, inherentAttrs, |
| 2525 | [&]() { return ::mlir::emitError(odsState.location); }); |
| 2526 | }); |
| 2527 | } |
| 2528 | |
| 2529 | |
| 2530 | } // namespace mlir::bufferization |
| 2531 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::ToBufferOp) |
| 2532 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::detail::ToBufferOpGenericAdaptorBase::Properties) |
| 2533 | |
| 2534 | namespace mlir::bufferization { |
| 2535 | |
| 2536 | |
| 2537 | //===----------------------------------------------------------------------===// |
| 2538 | // ::mlir::bufferization::ToTensorOp definitions |
| 2539 | //===----------------------------------------------------------------------===// |
| 2540 | |
| 2541 | namespace detail { |
| 2542 | |
| 2543 | ToTensorOpGenericAdaptorBase::ToTensorOpGenericAdaptorBase(ToTensorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} |
| 2544 | |
| 2545 | ::mlir::UnitAttr ToTensorOpGenericAdaptorBase::getRestrictAttr() { |
| 2546 | auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().restrict); |
| 2547 | if (!attr) |
| 2548 | attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); |
| 2549 | return attr; |
| 2550 | } |
| 2551 | |
| 2552 | bool ToTensorOpGenericAdaptorBase::getRestrict() { |
| 2553 | auto attr = getRestrictAttr(); |
| 2554 | if (!attr) |
| 2555 | return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; |
| 2556 | return attr != nullptr; |
| 2557 | } |
| 2558 | |
| 2559 | ::mlir::UnitAttr ToTensorOpGenericAdaptorBase::getWritableAttr() { |
| 2560 | auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().writable); |
| 2561 | if (!attr) |
| 2562 | attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); |
| 2563 | return attr; |
| 2564 | } |
| 2565 | |
| 2566 | bool ToTensorOpGenericAdaptorBase::getWritable() { |
| 2567 | auto attr = getWritableAttr(); |
| 2568 | if (!attr) |
| 2569 | return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; |
| 2570 | return attr != nullptr; |
| 2571 | } |
| 2572 | |
| 2573 | |
| 2574 | } // namespace detail |
| 2575 | ToTensorOpAdaptor::ToTensorOpAdaptor(ToTensorOp op) : ToTensorOpGenericAdaptor(op->getOperands(), op) {} |
| 2576 | |
| 2577 | ::llvm::LogicalResult ToTensorOpAdaptor::verify(::mlir::Location loc) { |
| 2578 | auto tblgen_restrict = getProperties().restrict; (void)tblgen_restrict; |
| 2579 | auto tblgen_writable = getProperties().writable; (void)tblgen_writable; |
| 2580 | |
| 2581 | if (tblgen_restrict && !((::llvm::isa<::mlir::UnitAttr>(tblgen_restrict)))) |
| 2582 | return emitError(loc, "'bufferization.to_tensor' op attribute 'restrict' failed to satisfy constraint: unit attribute" ); |
| 2583 | |
| 2584 | if (tblgen_writable && !((::llvm::isa<::mlir::UnitAttr>(tblgen_writable)))) |
| 2585 | return emitError(loc, "'bufferization.to_tensor' op attribute 'writable' failed to satisfy constraint: unit attribute" ); |
| 2586 | return ::mlir::success(); |
| 2587 | } |
| 2588 | |
| 2589 | ::llvm::LogicalResult ToTensorOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 2590 | ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); |
| 2591 | if (!dict) { |
| 2592 | emitError() << "expected DictionaryAttr to set properties" ; |
| 2593 | return ::mlir::failure(); |
| 2594 | } |
| 2595 | |
| 2596 | { |
| 2597 | auto attr = dict.get("restrict" ); |
| 2598 | if (::mlir::failed(::mlir::detail::setAttributeProperty( |
| 2599 | prop.restrict, attr, "restrict" , emitError))) |
| 2600 | return ::mlir::failure(); |
| 2601 | } |
| 2602 | |
| 2603 | { |
| 2604 | auto attr = dict.get("writable" ); |
| 2605 | if (::mlir::failed(::mlir::detail::setAttributeProperty( |
| 2606 | prop.writable, attr, "writable" , emitError))) |
| 2607 | return ::mlir::failure(); |
| 2608 | } |
| 2609 | return ::mlir::success(); |
| 2610 | } |
| 2611 | |
| 2612 | ::mlir::Attribute ToTensorOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { |
| 2613 | ::mlir::SmallVector<::mlir::NamedAttribute> attrs; |
| 2614 | ::mlir::Builder odsBuilder{ctx}; |
| 2615 | ::mlir::detail::appendAttributeProperty(attrs, "restrict" , prop.restrict); |
| 2616 | ::mlir::detail::appendAttributeProperty(attrs, "writable" , prop.writable); |
| 2617 | |
| 2618 | if (!attrs.empty()) |
| 2619 | return odsBuilder.getDictionaryAttr(attrs); |
| 2620 | return {}; |
| 2621 | } |
| 2622 | |
| 2623 | llvm::hash_code ToTensorOp::computePropertiesHash(const Properties &prop) { |
| 2624 | using llvm::hash_value; |
| 2625 | return llvm::hash_combine( |
| 2626 | llvm::hash_value(prop.restrict.getAsOpaquePointer()), |
| 2627 | llvm::hash_value(prop.writable.getAsOpaquePointer())); |
| 2628 | } |
| 2629 | |
| 2630 | std::optional<mlir::Attribute> ToTensorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { |
| 2631 | if (name == "restrict" ) |
| 2632 | return prop.restrict; |
| 2633 | |
| 2634 | if (name == "writable" ) |
| 2635 | return prop.writable; |
| 2636 | return std::nullopt; |
| 2637 | } |
| 2638 | |
| 2639 | void ToTensorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { |
| 2640 | if (name == "restrict" ) { |
| 2641 | prop.restrict = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.restrict)>>(value); |
| 2642 | return; |
| 2643 | } |
| 2644 | |
| 2645 | if (name == "writable" ) { |
| 2646 | prop.writable = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.writable)>>(value); |
| 2647 | return; |
| 2648 | } |
| 2649 | } |
| 2650 | |
| 2651 | void ToTensorOp::walkInherentAttrs(::mlir::MLIRContext *ctx, Properties &prop, ::llvm::function_ref<void(::llvm::StringRef, ::mlir::Attribute &)> visitor) { |
| 2652 | if (prop.restrict) { |
| 2653 | ::mlir::Attribute value = prop.restrict; |
| 2654 | ::mlir::Attribute originalValue = value; |
| 2655 | visitor("restrict" , value); |
| 2656 | if (value != originalValue) |
| 2657 | setInherentAttr(prop, "restrict" , value); |
| 2658 | } |
| 2659 | |
| 2660 | if (prop.writable) { |
| 2661 | ::mlir::Attribute value = prop.writable; |
| 2662 | ::mlir::Attribute originalValue = value; |
| 2663 | visitor("writable" , value); |
| 2664 | if (value != originalValue) |
| 2665 | setInherentAttr(prop, "writable" , value); |
| 2666 | } |
| 2667 | } |
| 2668 | |
| 2669 | ::llvm::LogicalResult ToTensorOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { |
| 2670 | { |
| 2671 | ::mlir::Attribute attr = attrs.get(getRestrictAttrName(opName)); |
| 2672 | if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(attr, "restrict" , emitError))) |
| 2673 | return ::mlir::failure(); |
| 2674 | } |
| 2675 | |
| 2676 | { |
| 2677 | ::mlir::Attribute attr = attrs.get(getWritableAttrName(opName)); |
| 2678 | if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(attr, "writable" , emitError))) |
| 2679 | return ::mlir::failure(); |
| 2680 | } |
| 2681 | return ::mlir::success(); |
| 2682 | } |
| 2683 | |
| 2684 | ::llvm::LogicalResult ToTensorOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { |
| 2685 | auto &prop = state.getOrAddProperties<Properties>(); (void)prop; |
| 2686 | if (::mlir::failed(reader.readOptionalAttribute(prop.restrict))) |
| 2687 | return ::mlir::failure(); |
| 2688 | |
| 2689 | if (::mlir::failed(reader.readOptionalAttribute(prop.writable))) |
| 2690 | return ::mlir::failure(); |
| 2691 | return ::mlir::success(); |
| 2692 | } |
| 2693 | |
| 2694 | void ToTensorOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { |
| 2695 | auto &prop = getProperties(); (void)prop; |
| 2696 | |
| 2697 | writer.writeOptionalAttribute(prop.restrict); |
| 2698 | |
| 2699 | writer.writeOptionalAttribute(prop.writable); |
| 2700 | } |
| 2701 | |
| 2702 | bool ToTensorOp::getRestrict() { |
| 2703 | auto attr = getRestrictAttr(); |
| 2704 | if (!attr) |
| 2705 | return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; |
| 2706 | return attr != nullptr; |
| 2707 | } |
| 2708 | |
| 2709 | bool ToTensorOp::getWritable() { |
| 2710 | auto attr = getWritableAttr(); |
| 2711 | if (!attr) |
| 2712 | return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; |
| 2713 | return attr != nullptr; |
| 2714 | } |
| 2715 | |
| 2716 | void ToTensorOp::setRestrict(bool attrValue) { |
| 2717 | auto &odsProp = getProperties().restrict; |
| 2718 | if (attrValue) |
| 2719 | odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); |
| 2720 | else |
| 2721 | odsProp = nullptr; |
| 2722 | } |
| 2723 | |
| 2724 | void ToTensorOp::setWritable(bool attrValue) { |
| 2725 | auto &odsProp = getProperties().writable; |
| 2726 | if (attrValue) |
| 2727 | odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); |
| 2728 | else |
| 2729 | odsProp = nullptr; |
| 2730 | } |
| 2731 | |
| 2732 | void ToTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value buffer, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) { |
| 2733 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 2734 | odsState.addOperands(buffer); |
| 2735 | if (restrict) { |
| 2736 | odsProperties.restrict = restrict; |
| 2737 | } |
| 2738 | if (writable) { |
| 2739 | odsProperties.writable = writable; |
| 2740 | } |
| 2741 | odsState.addTypes(result); |
| 2742 | } |
| 2743 | |
| 2744 | ToTensorOp ToTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value buffer, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) { |
| 2745 | ::mlir::OperationState __state__(location, getOperationName()); |
| 2746 | build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 2747 | auto __res__ = builder.create(__state__); |
| 2748 | assert((::llvm::isa<ToTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 2749 | return ::llvm::cast<ToTensorOp>(__res__); |
| 2750 | } |
| 2751 | |
| 2752 | ToTensorOp ToTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value buffer, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) { |
| 2753 | return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 2754 | } |
| 2755 | |
| 2756 | void ToTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value buffer, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) { |
| 2757 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 2758 | odsState.addOperands(buffer); |
| 2759 | if (restrict) { |
| 2760 | odsProperties.restrict = restrict; |
| 2761 | } |
| 2762 | if (writable) { |
| 2763 | odsProperties.writable = writable; |
| 2764 | } |
| 2765 | assert(resultTypes.size() == 1u && "mismatched number of results" ); |
| 2766 | odsState.addTypes(resultTypes); |
| 2767 | } |
| 2768 | |
| 2769 | ToTensorOp ToTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value buffer, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) { |
| 2770 | ::mlir::OperationState __state__(location, getOperationName()); |
| 2771 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 2772 | auto __res__ = builder.create(__state__); |
| 2773 | assert((::llvm::isa<ToTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 2774 | return ::llvm::cast<ToTensorOp>(__res__); |
| 2775 | } |
| 2776 | |
| 2777 | ToTensorOp ToTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value buffer, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) { |
| 2778 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 2779 | } |
| 2780 | |
| 2781 | void ToTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value buffer, /*optional*/bool restrict, /*optional*/bool writable) { |
| 2782 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 2783 | odsState.addOperands(buffer); |
| 2784 | if (restrict) { |
| 2785 | odsProperties.restrict = ((restrict) ? odsBuilder.getUnitAttr() : nullptr); |
| 2786 | } |
| 2787 | if (writable) { |
| 2788 | odsProperties.writable = ((writable) ? odsBuilder.getUnitAttr() : nullptr); |
| 2789 | } |
| 2790 | odsState.addTypes(result); |
| 2791 | } |
| 2792 | |
| 2793 | ToTensorOp ToTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value buffer, /*optional*/bool restrict, /*optional*/bool writable) { |
| 2794 | ::mlir::OperationState __state__(location, getOperationName()); |
| 2795 | build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 2796 | auto __res__ = builder.create(__state__); |
| 2797 | assert((::llvm::isa<ToTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 2798 | return ::llvm::cast<ToTensorOp>(__res__); |
| 2799 | } |
| 2800 | |
| 2801 | ToTensorOp ToTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value buffer, /*optional*/bool restrict, /*optional*/bool writable) { |
| 2802 | return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 2803 | } |
| 2804 | |
| 2805 | void ToTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value buffer, /*optional*/bool restrict, /*optional*/bool writable) { |
| 2806 | auto &odsProperties = odsState.getOrAddProperties<Properties>(); |
| 2807 | odsState.addOperands(buffer); |
| 2808 | if (restrict) { |
| 2809 | odsProperties.restrict = ((restrict) ? odsBuilder.getUnitAttr() : nullptr); |
| 2810 | } |
| 2811 | if (writable) { |
| 2812 | odsProperties.writable = ((writable) ? odsBuilder.getUnitAttr() : nullptr); |
| 2813 | } |
| 2814 | assert(resultTypes.size() == 1u && "mismatched number of results" ); |
| 2815 | odsState.addTypes(resultTypes); |
| 2816 | } |
| 2817 | |
| 2818 | ToTensorOp ToTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value buffer, /*optional*/bool restrict, /*optional*/bool writable) { |
| 2819 | ::mlir::OperationState __state__(location, getOperationName()); |
| 2820 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 2821 | auto __res__ = builder.create(__state__); |
| 2822 | assert((::llvm::isa<ToTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 2823 | return ::llvm::cast<ToTensorOp>(__res__); |
| 2824 | } |
| 2825 | |
| 2826 | ToTensorOp ToTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value buffer, /*optional*/bool restrict, /*optional*/bool writable) { |
| 2827 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable)); |
| 2828 | } |
| 2829 | |
| 2830 | void ToTensorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 2831 | assert(operands.size() == 1u && "mismatched number of parameters" ); |
| 2832 | odsState.addOperands(operands); |
| 2833 | buildPropertiesAndDiscardableAttributes(odsState, attributes); |
| 2834 | assert(resultTypes.size() == 1u && "mismatched number of return types" ); |
| 2835 | odsState.addTypes(resultTypes); |
| 2836 | } |
| 2837 | |
| 2838 | ToTensorOp ToTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 2839 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH |
| 2840 | |
| 2841 | ::mlir::OperationState __state__(location, getOperationName()); |
| 2842 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 2843 | auto __res__ = builder.create(__state__); |
| 2844 | assert((::llvm::isa<ToTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 2845 | return ::llvm::cast<ToTensorOp>(__res__); |
| 2846 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP |
| 2847 | } |
| 2848 | |
| 2849 | ToTensorOp ToTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 2850 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH |
| 2851 | |
| 2852 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes)); |
| 2853 | LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP |
| 2854 | } |
| 2855 | |
| 2856 | void ToTensorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 2857 | assert(operands.size() == 1u && "mismatched number of parameters" ); |
| 2858 | odsState.addOperands(operands); |
| 2859 | odsState.useProperties(const_cast<Properties&>(properties)); |
| 2860 | odsState.addAttributes(discardableAttributes); |
| 2861 | assert(resultTypes.size() == 1u && "mismatched number of return types" ); |
| 2862 | odsState.addTypes(resultTypes); |
| 2863 | } |
| 2864 | |
| 2865 | ToTensorOp ToTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 2866 | ::mlir::OperationState __state__(location, getOperationName()); |
| 2867 | build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 2868 | auto __res__ = builder.create(__state__); |
| 2869 | assert((::llvm::isa<ToTensorOp>(__res__)) && "builder didn't return the right type" ); |
| 2870 | return ::llvm::cast<ToTensorOp>(__res__); |
| 2871 | } |
| 2872 | |
| 2873 | ToTensorOp ToTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { |
| 2874 | return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes)); |
| 2875 | } |
| 2876 | |
| 2877 | ::llvm::LogicalResult ToTensorOp::verifyInvariantsImpl() { |
| 2878 | auto tblgen_restrict = getProperties().restrict; (void)tblgen_restrict; |
| 2879 | auto tblgen_writable = getProperties().writable; (void)tblgen_writable; |
| 2880 | |
| 2881 | if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(*this, tblgen_restrict, "restrict" ))) |
| 2882 | return ::mlir::failure(); |
| 2883 | |
| 2884 | if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(*this, tblgen_writable, "writable" ))) |
| 2885 | return ::mlir::failure(); |
| 2886 | { |
| 2887 | unsigned index = 0; (void)index; |
| 2888 | auto valueGroup0 = getODSOperands(0); |
| 2889 | |
| 2890 | for (auto v : valueGroup0) { |
| 2891 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps9(*this, v.getType(), "operand" , index++))) |
| 2892 | return ::mlir::failure(); |
| 2893 | } |
| 2894 | } |
| 2895 | { |
| 2896 | unsigned index = 0; (void)index; |
| 2897 | auto valueGroup0 = getODSResults(0); |
| 2898 | |
| 2899 | for (auto v : valueGroup0) { |
| 2900 | if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps2(*this, v.getType(), "result" , index++))) |
| 2901 | return ::mlir::failure(); |
| 2902 | } |
| 2903 | } |
| 2904 | if (!((::mlir::bufferization::detail::typesMatchAfterBufferization((*this->getOperation()), (*this->getODSResults(0).begin()), (*this->getODSOperands(0).begin()))))) |
| 2905 | return emitOpError("failed to verify that specified tensor and buffer types match" ); |
| 2906 | return ::mlir::success(); |
| 2907 | } |
| 2908 | |
| 2909 | ::llvm::LogicalResult ToTensorOp::verifyInvariants() { |
| 2910 | return verifyInvariantsImpl(); |
| 2911 | } |
| 2912 | |
| 2913 | ::mlir::ParseResult ToTensorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { |
| 2914 | ::mlir::OpAsmParser::UnresolvedOperand bufferRawOperand{}; |
| 2915 | ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> bufferOperands(&bufferRawOperand, 1); ::llvm::SMLoc bufferOperandsLoc; |
| 2916 | (void)bufferOperandsLoc; |
| 2917 | ::mlir::Type bufferRawType{}; |
| 2918 | ::llvm::ArrayRef<::mlir::Type> bufferTypes(&bufferRawType, 1); |
| 2919 | ::mlir::Type resultRawType{}; |
| 2920 | ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); |
| 2921 | |
| 2922 | bufferOperandsLoc = parser.getCurrentLocation(); |
| 2923 | if (parser.parseOperand(bufferRawOperand)) |
| 2924 | return ::mlir::failure(); |
| 2925 | if (::mlir::succeeded(parser.parseOptionalKeyword("restrict" ))) { |
| 2926 | result.getOrAddProperties<ToTensorOp::Properties>().restrict = parser.getBuilder().getUnitAttr(); } |
| 2927 | if (::mlir::succeeded(parser.parseOptionalKeyword("writable" ))) { |
| 2928 | result.getOrAddProperties<ToTensorOp::Properties>().writable = parser.getBuilder().getUnitAttr(); } |
| 2929 | { |
| 2930 | auto loc = parser.getCurrentLocation();(void)loc; |
| 2931 | if (parser.parseOptionalAttrDict(result.attributes)) |
| 2932 | return ::mlir::failure(); |
| 2933 | if (result.attributes.get("restrict" )) |
| 2934 | return parser.emitError(loc, "inherent attribute 'restrict' cannot be parsed from attr-dict when strict properties in assembly format is enabled" ); |
| 2935 | if (result.attributes.get("writable" )) |
| 2936 | return parser.emitError(loc, "inherent attribute 'writable' cannot be parsed from attr-dict when strict properties in assembly format is enabled" ); |
| 2937 | } |
| 2938 | if (parser.parseColon()) |
| 2939 | return ::mlir::failure(); |
| 2940 | |
| 2941 | { |
| 2942 | ::mlir::bufferization::BufferLikeType type; |
| 2943 | if (parser.parseCustomTypeWithFallback(type)) |
| 2944 | return ::mlir::failure(); |
| 2945 | bufferRawType = type; |
| 2946 | } |
| 2947 | if (parser.parseKeyword("to" )) |
| 2948 | return ::mlir::failure(); |
| 2949 | |
| 2950 | { |
| 2951 | ::mlir::bufferization::TensorLikeType type; |
| 2952 | if (parser.parseCustomTypeWithFallback(type)) |
| 2953 | return ::mlir::failure(); |
| 2954 | resultRawType = type; |
| 2955 | } |
| 2956 | result.addTypes(resultTypes); |
| 2957 | // coverity[ARRAY_VS_SINGLETON] |
| 2958 | if (parser.resolveOperands(bufferOperands, bufferTypes, bufferOperandsLoc, result.operands)) |
| 2959 | return ::mlir::failure(); |
| 2960 | return ::mlir::success(); |
| 2961 | } |
| 2962 | |
| 2963 | LLVM_ATTRIBUTE_MINSIZE void ToTensorOp::print(::mlir::OpAsmPrinter &_odsPrinter) { |
| 2964 | _odsPrinter << ' '; |
| 2965 | _odsPrinter << getBuffer(); |
| 2966 | if ((getRestrictAttr() && getRestrictAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { |
| 2967 | _odsPrinter << " restrict" ; |
| 2968 | } |
| 2969 | if ((getWritableAttr() && getWritableAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { |
| 2970 | _odsPrinter << " writable" ; |
| 2971 | } |
| 2972 | _odsPrinter.printOptionalAttrDict((*this)->getDiscardableAttrDictionary().getValue()); |
| 2973 | _odsPrinter << " :" ; |
| 2974 | _odsPrinter << ' '; |
| 2975 | { |
| 2976 | auto type = getBuffer().getType(); |
| 2977 | if (auto validType = ::llvm::dyn_cast<::mlir::bufferization::BufferLikeType>(type)) |
| 2978 | _odsPrinter.printStrippedAttrOrType(validType); |
| 2979 | else |
| 2980 | _odsPrinter << type; |
| 2981 | } |
| 2982 | _odsPrinter << " to" ; |
| 2983 | _odsPrinter << ' '; |
| 2984 | { |
| 2985 | auto type = getResult().getType(); |
| 2986 | if (auto validType = ::llvm::dyn_cast<::mlir::bufferization::TensorLikeType>(type)) |
| 2987 | _odsPrinter.printStrippedAttrOrType(validType); |
| 2988 | else |
| 2989 | _odsPrinter << type; |
| 2990 | } |
| 2991 | } |
| 2992 | |
| 2993 | void ToTensorOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { |
| 2994 | { |
| 2995 | auto valueRange = getODSOperandIndexAndLength(0); |
| 2996 | for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { |
| 2997 | effects.emplace_back(::mlir::MemoryEffects::Read::get(), &getOperation()->getOpOperand(idx), 0, true, ::mlir::SideEffects::DefaultResource::get()); |
| 2998 | } |
| 2999 | } |
| 3000 | } |
| 3001 | |
| 3002 | void ToTensorOp::buildPropertiesAndDiscardableAttributes(::mlir::OperationState &odsState, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { |
| 3003 | Properties &properties = odsState.getOrAddProperties<Properties>(); |
| 3004 | populateDefaultProperties(odsState.name, properties); |
| 3005 | const ::llvm::StringRef inherentNames[] = {"restrict" , "writable" }; |
| 3006 | ::mlir::detail::splitPropertiesAndDiscardableAttributes( |
| 3007 | odsState, attributes, inherentNames, [&](::mlir::DictionaryAttr inherentAttrs) { |
| 3008 | return setPropertiesFromAttr(properties, inherentAttrs, |
| 3009 | [&]() { return ::mlir::emitError(odsState.location); }); |
| 3010 | }); |
| 3011 | } |
| 3012 | |
| 3013 | |
| 3014 | } // namespace mlir::bufferization |
| 3015 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::ToTensorOp) |
| 3016 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::detail::ToTensorOpGenericAdaptorBase::Properties) |
| 3017 | |
| 3018 | |
| 3019 | #endif // GET_OP_CLASSES |
| 3020 | |
| 3021 | |