/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |* *| |* Op Definitions *| |* *| |* Automatically generated file, do not edit! *| |* From: MemRefOps.td *| |* *| \*===----------------------------------------------------------------------===*/ #ifdef GET_OP_LIST #undef GET_OP_LIST ::mlir::memref::AssumeAlignmentOp, ::mlir::memref::AtomicRMWOp, ::mlir::memref::AtomicYieldOp, ::mlir::memref::CopyOp, ::mlir::memref::DistinctObjectsOp, ::mlir::memref::GenericAtomicRMWOp, ::mlir::memref::LoadOp, ::mlir::memref::AllocOp, ::mlir::memref::AllocaOp, ::mlir::memref::AllocaScopeOp, ::mlir::memref::AllocaScopeReturnOp, ::mlir::memref::CastOp, ::mlir::memref::CollapseShapeOp, ::mlir::memref::DeallocOp, ::mlir::memref::DimOp, ::mlir::memref::DmaStartOp, ::mlir::memref::DmaWaitOp, ::mlir::memref::ExpandShapeOp, ::mlir::memref::ExtractAlignedPointerAsIndexOp, ::mlir::memref::ExtractStridedMetadataOp, ::mlir::memref::GetGlobalOp, ::mlir::memref::GlobalOp, ::mlir::memref::MemorySpaceCastOp, ::mlir::memref::PrefetchOp, ::mlir::memref::RankOp, ::mlir::memref::ReallocOp, ::mlir::memref::ReinterpretCastOp, ::mlir::memref::ReshapeOp, ::mlir::memref::StoreOp, ::mlir::memref::TransposeOp, ::mlir::memref::ViewOp, ::mlir::memref::SubViewOp #endif // GET_OP_LIST #ifdef GET_OP_CLASSES #undef GET_OP_CLASSES //===----------------------------------------------------------------------===// // Local Utility Method Definitions //===----------------------------------------------------------------------===// static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps1( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be memref of any non-token type values, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps2( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((type.isSignlessInteger())) || ((::llvm::isa<::mlir::FloatType>(type))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be signless integer or floating-point, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps3( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger())) || ((::llvm::isa<::mlir::FloatType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be memref of signless integer or floating-point values, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps4( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((::llvm::isa<::mlir::IndexType>(type)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be variadic of index, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps5( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(!((::llvm::isa<::mlir::TokenType>(type))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be any non-token type, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps6( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::BaseMemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be ranked or unranked memref of any non-token type values, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps7( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be variadic of memref of any non-token type values, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps8( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(!((::llvm::isa<::mlir::TokenType>(type))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be variadic of any non-token type, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps9( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && (( ::llvm::cast<::mlir::MemRefType>(type).isStrided() )))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be strided memref of any non-token type values, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps10( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((::llvm::isa<::mlir::UnrankedMemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() >= 1)))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be unranked.memref of any non-token type values or non-0-ranked.memref of any non-token type values, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps11( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((::llvm::isa<::mlir::IndexType>(type)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be index, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps12( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && (( ::llvm::cast<::mlir::MemRefType>(type).isStrided() ))) && ((((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() == 0)))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be strided memref of any non-token type values of rank 0, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps13( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape())))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be statically shaped memref of any non-token type values, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps14( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() == 1))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 1D memref of any non-token type values, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps15( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger())) || ((::llvm::isa<::mlir::IndexType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() == 1))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 1D memref of signless integer or index values, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_MemRefOps16( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(8)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() == 1))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 1D memref of 8-bit signless integer values, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps1( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32)))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getValue().isStrictlyPositive())))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: 32-bit signless integer attribute whose value is positive"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps1( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_MemRefOps1(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps2( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::arith::AtomicRMWKindAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: allowed 64-bit signless integer cases: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps2( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_MemRefOps2(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps3( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::BoolAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: bool attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps3( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_MemRefOps3(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps4( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))) && (((::llvm::cast<::mlir::IntegerAttr>(attr).getValue().isStrictlyPositive())) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getValue().isPowerOf2()))))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive and whose value is a power of two > 0"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps4( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_MemRefOps4(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps5( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); }))); })))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Array of 64-bit integer array attributes"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps5( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_MemRefOps5(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps6( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: i64 dense array attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps6( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_MemRefOps6(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps7( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::FlatSymbolRefAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: flat symbol reference attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps7( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_MemRefOps7(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps8( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::StringAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: string attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps8( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_MemRefOps8(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps9( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::TypeAttr>(attr))) && ((::llvm::isa<::mlir::MemRefType>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))) && ((true)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: memref type attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps9( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_MemRefOps9(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps10( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((true))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: any attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps10( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_MemRefOps10(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps11( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::UnitAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: unit attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps11( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_MemRefOps11(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps12( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32)))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() >= 0)) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() <= 3)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: 32-bit signless integer attribute whose minimum value is 0 whose maximum value is 3"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps12( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_MemRefOps12(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps13( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::AffineMapAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: AffineMap attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_MemRefOps13( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_MemRefOps13(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_region_constraint_MemRefOps1( ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, unsigned regionIndex) { if (!((true))) { return op->emitOpError("region #") << regionIndex << (regionName.empty() ? " " : " ('" + regionName + "') ") << "failed to verify constraint: any region"; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_region_constraint_MemRefOps2( ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, unsigned regionIndex) { if (!((::llvm::hasNItems(region, 1)))) { return op->emitOpError("region #") << regionIndex << (regionName.empty() ? " " : " ('" + regionName + "') ") << "failed to verify constraint: region with 1 blocks"; } return ::mlir::success(); } namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::AssumeAlignmentOp definitions //===----------------------------------------------------------------------===// namespace detail { AssumeAlignmentOpGenericAdaptorBase::AssumeAlignmentOpGenericAdaptorBase(AssumeAlignmentOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} uint32_t AssumeAlignmentOpGenericAdaptorBase::getAlignment() { auto attr = getAlignmentAttr(); return attr.getValue().getZExtValue(); } } // namespace detail AssumeAlignmentOpAdaptor::AssumeAlignmentOpAdaptor(AssumeAlignmentOp op) : AssumeAlignmentOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AssumeAlignmentOpAdaptor::verify(::mlir::Location loc) { auto tblgen_alignment = getProperties().alignment; (void)tblgen_alignment; if (!tblgen_alignment) return emitError(loc, "'memref.assume_alignment' op requires attribute 'alignment'"); if (tblgen_alignment && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_alignment))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getType().isSignlessInteger(32)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getValue().isStrictlyPositive())))) return emitError(loc, "'memref.assume_alignment' op attribute 'alignment' failed to satisfy constraint: 32-bit signless integer attribute whose value is positive"); return ::mlir::success(); } ::llvm::LogicalResult AssumeAlignmentOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.alignment; auto attr = dict.get("alignment"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `alignment` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute AssumeAlignmentOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.alignment; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("alignment", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code AssumeAlignmentOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.alignment.getAsOpaquePointer())); } std::optional AssumeAlignmentOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "alignment") return prop.alignment; return std::nullopt; } void AssumeAlignmentOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "alignment") { prop.alignment = ::llvm::dyn_cast_or_null>(value); return; } } void AssumeAlignmentOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.alignment) attrs.append("alignment", prop.alignment); } ::llvm::LogicalResult AssumeAlignmentOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAlignmentAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps1(attr, "alignment", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult AssumeAlignmentOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.alignment))) return ::mlir::failure(); return ::mlir::success(); } void AssumeAlignmentOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.alignment); } uint32_t AssumeAlignmentOp::getAlignment() { auto attr = getAlignmentAttr(); return attr.getValue().getZExtValue(); } void AssumeAlignmentOp::setAlignment(uint32_t attrValue) { getProperties().alignment = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void AssumeAlignmentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value memref, ::mlir::IntegerAttr alignment) { odsState.addOperands(memref); odsState.getOrAddProperties().alignment = alignment; odsState.addTypes(result); } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value memref, ::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(memref), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value memref, ::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(result), std::forward(memref), std::forward(alignment)); } void AssumeAlignmentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value memref, ::mlir::IntegerAttr alignment) { odsState.addOperands(memref); odsState.getOrAddProperties().alignment = alignment; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AssumeAlignmentOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value memref, ::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memref), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value memref, ::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(memref), std::forward(alignment)); } void AssumeAlignmentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value memref, ::mlir::IntegerAttr alignment) { odsState.addOperands(memref); odsState.getOrAddProperties().alignment = alignment; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value memref, ::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(memref), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value memref, ::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(memref), std::forward(alignment)); } void AssumeAlignmentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value memref, uint32_t alignment) { odsState.addOperands(memref); odsState.getOrAddProperties().alignment = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), alignment); odsState.addTypes(result); } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value memref, uint32_t alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(memref), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value memref, uint32_t alignment) { return create(builder, builder.getLoc(), std::forward(result), std::forward(memref), std::forward(alignment)); } void AssumeAlignmentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value memref, uint32_t alignment) { odsState.addOperands(memref); odsState.getOrAddProperties().alignment = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), alignment); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AssumeAlignmentOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value memref, uint32_t alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memref), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value memref, uint32_t alignment) { return create(builder, builder.getLoc(), std::forward(memref), std::forward(alignment)); } void AssumeAlignmentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value memref, uint32_t alignment) { odsState.addOperands(memref); odsState.getOrAddProperties().alignment = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), alignment); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value memref, uint32_t alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(memref), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value memref, uint32_t alignment) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(memref), std::forward(alignment)); } void AssumeAlignmentOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void AssumeAlignmentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AssumeAlignmentOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void AssumeAlignmentOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void AssumeAlignmentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AssumeAlignmentOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AssumeAlignmentOp AssumeAlignmentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult AssumeAlignmentOp::verifyInvariantsImpl() { auto tblgen_alignment = getProperties().alignment; (void)tblgen_alignment; if (!tblgen_alignment) return emitOpError("requires attribute 'alignment'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps1(*this, tblgen_alignment, "alignment"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult AssumeAlignmentOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult AssumeAlignmentOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[0].getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult AssumeAlignmentOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand memrefRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> memrefOperands(&memrefRawOperand, 1); ::llvm::SMLoc memrefOperandsLoc; (void)memrefOperandsLoc; ::mlir::IntegerAttr alignmentAttr; ::mlir::Type memrefRawType{}; ::llvm::ArrayRef<::mlir::Type> memrefTypes(&memrefRawType, 1); memrefOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(memrefRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(alignmentAttr, parser.getBuilder().getIntegerType(32))) { return ::mlir::failure(); } if (alignmentAttr) result.getOrAddProperties().alignment = alignmentAttr; { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); memrefRawType = type; } result.addTypes(memrefTypes[0]); if (parser.resolveOperands(memrefOperands, memrefTypes, memrefOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void AssumeAlignmentOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getMemref(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getAlignmentAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("alignment"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getMemref().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void AssumeAlignmentOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::AssumeAlignmentOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::detail::AssumeAlignmentOpGenericAdaptorBase::Properties) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::AtomicRMWOp definitions //===----------------------------------------------------------------------===// namespace detail { AtomicRMWOpGenericAdaptorBase::AtomicRMWOpGenericAdaptorBase(AtomicRMWOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair AtomicRMWOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::arith::AtomicRMWKind AtomicRMWOpGenericAdaptorBase::getKind() { auto attr = getKindAttr(); return attr.getValue(); } } // namespace detail AtomicRMWOpAdaptor::AtomicRMWOpAdaptor(AtomicRMWOp op) : AtomicRMWOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AtomicRMWOpAdaptor::verify(::mlir::Location loc) { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitError(loc, "'memref.atomic_rmw' op requires attribute 'kind'"); if (tblgen_kind && !((::llvm::isa<::mlir::arith::AtomicRMWKindAttr>(tblgen_kind)))) return emitError(loc, "'memref.atomic_rmw' op attribute 'kind' failed to satisfy constraint: allowed 64-bit signless integer cases: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15"); return ::mlir::success(); } std::pair AtomicRMWOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange AtomicRMWOp::getIndicesMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult AtomicRMWOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.kind; auto attr = dict.get("kind"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kind` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute AtomicRMWOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.kind; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kind", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code AtomicRMWOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.kind.getAsOpaquePointer())); } std::optional AtomicRMWOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "kind") return prop.kind; return std::nullopt; } void AtomicRMWOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "kind") { prop.kind = ::llvm::dyn_cast_or_null>(value); return; } } void AtomicRMWOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.kind) attrs.append("kind", prop.kind); } ::llvm::LogicalResult AtomicRMWOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps2(attr, "kind", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult AtomicRMWOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.kind))) return ::mlir::failure(); return ::mlir::success(); } void AtomicRMWOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.kind); } ::mlir::arith::AtomicRMWKind AtomicRMWOp::getKind() { auto attr = getKindAttr(); return attr.getValue(); } void AtomicRMWOp::setKind(::mlir::arith::AtomicRMWKind attrValue) { getProperties().kind = ::mlir::arith::AtomicRMWKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void AtomicRMWOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::arith::AtomicRMWKindAttr kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { odsState.addOperands(value); odsState.addOperands(memref); odsState.addOperands(indices); odsState.getOrAddProperties().kind = kind; odsState.addTypes(result); } AtomicRMWOp AtomicRMWOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::arith::AtomicRMWKindAttr kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(kind), std::forward(value), std::forward(memref), std::forward(indices)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicRMWOp AtomicRMWOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::arith::AtomicRMWKindAttr kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { return create(builder, builder.getLoc(), std::forward(result), std::forward(kind), std::forward(value), std::forward(memref), std::forward(indices)); } void AtomicRMWOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::arith::AtomicRMWKindAttr kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { odsState.addOperands(value); odsState.addOperands(memref); odsState.addOperands(indices); odsState.getOrAddProperties().kind = kind; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AtomicRMWOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } AtomicRMWOp AtomicRMWOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::arith::AtomicRMWKindAttr kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(value), std::forward(memref), std::forward(indices)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicRMWOp AtomicRMWOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::arith::AtomicRMWKindAttr kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(value), std::forward(memref), std::forward(indices)); } void AtomicRMWOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::arith::AtomicRMWKindAttr kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { odsState.addOperands(value); odsState.addOperands(memref); odsState.addOperands(indices); odsState.getOrAddProperties().kind = kind; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AtomicRMWOp AtomicRMWOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::arith::AtomicRMWKindAttr kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(value), std::forward(memref), std::forward(indices)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicRMWOp AtomicRMWOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::arith::AtomicRMWKindAttr kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(value), std::forward(memref), std::forward(indices)); } void AtomicRMWOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::arith::AtomicRMWKind kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { odsState.addOperands(value); odsState.addOperands(memref); odsState.addOperands(indices); odsState.getOrAddProperties().kind = ::mlir::arith::AtomicRMWKindAttr::get(odsBuilder.getContext(), kind); odsState.addTypes(result); } AtomicRMWOp AtomicRMWOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::arith::AtomicRMWKind kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(kind), std::forward(value), std::forward(memref), std::forward(indices)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicRMWOp AtomicRMWOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::arith::AtomicRMWKind kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { return create(builder, builder.getLoc(), std::forward(result), std::forward(kind), std::forward(value), std::forward(memref), std::forward(indices)); } void AtomicRMWOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::arith::AtomicRMWKind kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { odsState.addOperands(value); odsState.addOperands(memref); odsState.addOperands(indices); odsState.getOrAddProperties().kind = ::mlir::arith::AtomicRMWKindAttr::get(odsBuilder.getContext(), kind); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AtomicRMWOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } AtomicRMWOp AtomicRMWOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::arith::AtomicRMWKind kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(kind), std::forward(value), std::forward(memref), std::forward(indices)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicRMWOp AtomicRMWOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::arith::AtomicRMWKind kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { return create(builder, builder.getLoc(), std::forward(kind), std::forward(value), std::forward(memref), std::forward(indices)); } void AtomicRMWOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::arith::AtomicRMWKind kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { odsState.addOperands(value); odsState.addOperands(memref); odsState.addOperands(indices); odsState.getOrAddProperties().kind = ::mlir::arith::AtomicRMWKindAttr::get(odsBuilder.getContext(), kind); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AtomicRMWOp AtomicRMWOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::arith::AtomicRMWKind kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(kind), std::forward(value), std::forward(memref), std::forward(indices)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicRMWOp AtomicRMWOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::arith::AtomicRMWKind kind, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(kind), std::forward(value), std::forward(memref), std::forward(indices)); } void AtomicRMWOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } AtomicRMWOp AtomicRMWOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicRMWOp AtomicRMWOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void AtomicRMWOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AtomicRMWOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } AtomicRMWOp AtomicRMWOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicRMWOp AtomicRMWOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void AtomicRMWOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AtomicRMWOp AtomicRMWOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicRMWOp AtomicRMWOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void AtomicRMWOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AtomicRMWOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } AtomicRMWOp AtomicRMWOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicRMWOp AtomicRMWOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult AtomicRMWOp::verifyInvariantsImpl() { auto tblgen_kind = getProperties().kind; (void)tblgen_kind; if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps2(*this, tblgen_kind, "kind"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps3(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType())))) return emitOpError("failed to verify that all of {value, result} have same type"); if (!((std::equal_to<>()(::llvm::cast((*this->getODSOperands(1).begin()).getType()).getElementType(), (*this->getODSOperands(0).begin()).getType())))) return emitOpError("failed to verify that value type matches element type of memref"); return ::mlir::success(); } ::llvm::LogicalResult AtomicRMWOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult AtomicRMWOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[0].getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult AtomicRMWOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::arith::AtomicRMWKindAttr kindAttr; ::mlir::OpAsmParser::UnresolvedOperand valueRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueOperands(&valueRawOperand, 1); ::llvm::SMLoc valueOperandsLoc; (void)valueOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand memrefRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> memrefOperands(&memrefRawOperand, 1); ::llvm::SMLoc memrefOperandsLoc; (void)memrefOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands; ::llvm::SMLoc indicesOperandsLoc; (void)indicesOperandsLoc; ::mlir::Type valueRawType{}; ::llvm::ArrayRef<::mlir::Type> valueTypes(&valueRawType, 1); ::mlir::Type memrefRawType{}; ::llvm::ArrayRef<::mlir::Type> memrefTypes(&memrefRawType, 1); ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); { ::llvm::StringRef attrStr; ::mlir::NamedAttrList attrStorage; auto loc = parser.getCurrentLocation(); if (parser.parseOptionalKeyword(&attrStr, {"addf","addi","andi","assign","maximumf","maxnumf","maxs","maxu","minimumf","minnumf","mins","minu","mulf","muli","ori","xori"})) { ::mlir::StringAttr attrVal; ::mlir::OptionalParseResult parseResult = parser.parseOptionalAttribute(attrVal, parser.getBuilder().getNoneType(), "kind", attrStorage); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); attrStr = attrVal.getValue(); } else { return parser.emitError(loc, "expected string or keyword containing one of the following enum values for attribute 'kind' [addf, addi, andi, assign, maximumf, maxnumf, maxs, maxu, minimumf, minnumf, mins, minu, mulf, muli, ori, xori]"); } } if (!attrStr.empty()) { auto attrOptional = ::mlir::arith::symbolizeAtomicRMWKind(attrStr); if (!attrOptional) return parser.emitError(loc, "invalid ") << "kind attribute specification: \"" << attrStr << '"';; kindAttr = ::mlir::arith::AtomicRMWKindAttr::get(parser.getBuilder().getContext(), *attrOptional); result.getOrAddProperties().kind = kindAttr; } } valueOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(valueRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); memrefOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(memrefRawOperand)) return ::mlir::failure(); if (parser.parseLSquare()) return ::mlir::failure(); indicesOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(indicesOperands)) return ::mlir::failure(); if (parser.parseRSquare()) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseLParen()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); valueRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); memrefRawType = type; } if (parser.parseRParen()) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resultRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); result.addTypes(resultTypes); if (parser.resolveOperands(valueOperands, valueTypes, valueOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(memrefOperands, memrefTypes, memrefOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void AtomicRMWOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; { auto caseValue = getKind(); auto caseValueStr = stringifyAtomicRMWKind(caseValue); _odsPrinter << caseValueStr; } _odsPrinter << ' '; _odsPrinter << getValue(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMemref(); _odsPrinter << "["; _odsPrinter << getIndices(); _odsPrinter << "]"; ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("kind"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' ' << "("; { auto type = getValue().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getMemref().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ")"; _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getResult().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void AtomicRMWOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { { auto valueRange = getODSOperandIndexAndLength(1); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Read::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get()); } } { auto valueRange = getODSOperandIndexAndLength(1); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get()); } } } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::AtomicRMWOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::detail::AtomicRMWOpGenericAdaptorBase::Properties) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::AtomicYieldOp definitions //===----------------------------------------------------------------------===// namespace detail { AtomicYieldOpGenericAdaptorBase::AtomicYieldOpGenericAdaptorBase(AtomicYieldOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail AtomicYieldOpAdaptor::AtomicYieldOpAdaptor(AtomicYieldOp op) : AtomicYieldOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AtomicYieldOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult AtomicYieldOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute AtomicYieldOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code AtomicYieldOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional AtomicYieldOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void AtomicYieldOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void AtomicYieldOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult AtomicYieldOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void AtomicYieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value result) { odsState.addOperands(result); } AtomicYieldOp AtomicYieldOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value result) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicYieldOp AtomicYieldOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value result) { return create(builder, builder.getLoc(), std::forward(result)); } void AtomicYieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value result) { odsState.addOperands(result); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } AtomicYieldOp AtomicYieldOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value result) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(result)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicYieldOp AtomicYieldOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value result) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(result)); } void AtomicYieldOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AtomicYieldOp AtomicYieldOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicYieldOp AtomicYieldOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void AtomicYieldOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AtomicYieldOp AtomicYieldOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicYieldOp AtomicYieldOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult AtomicYieldOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult AtomicYieldOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult AtomicYieldOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand resultRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> resultOperands(&resultRawOperand, 1); ::llvm::SMLoc resultOperandsLoc; (void)resultOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); resultOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(resultRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resultRawType = type; } if (parser.resolveOperands(resultOperands, resultTypes, resultOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void AtomicYieldOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getResult(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getResult().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void AtomicYieldOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::AtomicYieldOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::CopyOp definitions //===----------------------------------------------------------------------===// namespace detail { CopyOpGenericAdaptorBase::CopyOpGenericAdaptorBase(CopyOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail CopyOpAdaptor::CopyOpAdaptor(CopyOp op) : CopyOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CopyOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult CopyOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute CopyOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code CopyOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional CopyOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void CopyOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void CopyOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult CopyOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void CopyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value target) { odsState.addOperands(source); odsState.addOperands(target); } CopyOp CopyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value source, ::mlir::Value target) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(source), std::forward(target)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyOp CopyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value source, ::mlir::Value target) { return create(builder, builder.getLoc(), std::forward(source), std::forward(target)); } void CopyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value target) { odsState.addOperands(source); odsState.addOperands(target); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CopyOp CopyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value target) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(source), std::forward(target)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyOp CopyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value target) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(source), std::forward(target)); } void CopyOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CopyOp CopyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyOp CopyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CopyOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CopyOp CopyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyOp CopyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult CopyOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CopyOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult CopyOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(&sourceRawOperand, 1); ::llvm::SMLoc sourceOperandsLoc; (void)sourceOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand targetRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(&targetRawOperand, 1); ::llvm::SMLoc targetOperandsLoc; (void)targetOperandsLoc; ::mlir::Type sourceRawType{}; ::llvm::ArrayRef<::mlir::Type> sourceTypes(&sourceRawType, 1); ::mlir::Type targetRawType{}; ::llvm::ArrayRef<::mlir::Type> targetTypes(&targetRawType, 1); sourceOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sourceRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); targetOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(targetRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::BaseMemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); sourceRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::BaseMemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); targetRawType = type; } if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(targetOperands, targetTypes, targetOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void CopyOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSource(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getTarget(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSource().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::BaseMemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getTarget().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::BaseMemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void CopyOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { { auto valueRange = getODSOperandIndexAndLength(0); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Read::get(), &getOperation()->getOpOperand(idx), 0, true, ::mlir::SideEffects::DefaultResource::get()); } } { auto valueRange = getODSOperandIndexAndLength(1); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), &getOperation()->getOpOperand(idx), 0, true, ::mlir::SideEffects::DefaultResource::get()); } } } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::CopyOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::DistinctObjectsOp definitions //===----------------------------------------------------------------------===// namespace detail { DistinctObjectsOpGenericAdaptorBase::DistinctObjectsOpGenericAdaptorBase(DistinctObjectsOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair DistinctObjectsOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } } // namespace detail DistinctObjectsOpAdaptor::DistinctObjectsOpAdaptor(DistinctObjectsOp op) : DistinctObjectsOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DistinctObjectsOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair DistinctObjectsOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange DistinctObjectsOp::getOperandsMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } std::pair DistinctObjectsOp::getODSResultIndexAndLength(unsigned index) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumResults() - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::llvm::LogicalResult DistinctObjectsOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute DistinctObjectsOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DistinctObjectsOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional DistinctObjectsOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void DistinctObjectsOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void DistinctObjectsOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult DistinctObjectsOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void DistinctObjectsOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); odsState.addTypes(resultTypes); } DistinctObjectsOp DistinctObjectsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DistinctObjectsOp DistinctObjectsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void DistinctObjectsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DistinctObjectsOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } DistinctObjectsOp DistinctObjectsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DistinctObjectsOp DistinctObjectsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void DistinctObjectsOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); odsState.addTypes(resultTypes); } DistinctObjectsOp DistinctObjectsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DistinctObjectsOp DistinctObjectsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void DistinctObjectsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DistinctObjectsOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } DistinctObjectsOp DistinctObjectsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DistinctObjectsOp DistinctObjectsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult DistinctObjectsOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps7(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DistinctObjectsOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult DistinctObjectsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> operandsOperands; ::llvm::SMLoc operandsOperandsLoc; (void)operandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> operandsTypes; operandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(operandsOperands)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(operandsTypes)) return ::mlir::failure(); if (parser.resolveOperands(operandsOperands, operandsTypes, operandsOperandsLoc, result.operands)) return ::mlir::failure(); ::llvm::SmallVector<::mlir::Type> inferredReturnTypes; if (::mlir::failed(DistinctObjectsOp::inferReturnTypes(parser.getContext(), result.location, result.operands, result.attributes.getDictionary(parser.getContext()), result.getRawProperties(), result.regions, inferredReturnTypes))) return ::mlir::failure(); result.addTypes(inferredReturnTypes); return ::mlir::success(); } void DistinctObjectsOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getOperands(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperands().getTypes(); } void DistinctObjectsOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::DistinctObjectsOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::GenericAtomicRMWOp definitions //===----------------------------------------------------------------------===// namespace detail { GenericAtomicRMWOpGenericAdaptorBase::GenericAtomicRMWOpGenericAdaptorBase(GenericAtomicRMWOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair GenericAtomicRMWOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } } // namespace detail GenericAtomicRMWOpAdaptor::GenericAtomicRMWOpAdaptor(GenericAtomicRMWOp op) : GenericAtomicRMWOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GenericAtomicRMWOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair GenericAtomicRMWOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange GenericAtomicRMWOp::getIndicesMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult GenericAtomicRMWOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute GenericAtomicRMWOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code GenericAtomicRMWOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional GenericAtomicRMWOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void GenericAtomicRMWOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void GenericAtomicRMWOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult GenericAtomicRMWOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } GenericAtomicRMWOp GenericAtomicRMWOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value memref, ValueRange ivs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memref), std::forward(ivs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GenericAtomicRMWOp GenericAtomicRMWOp::create(::mlir::ImplicitLocOpBuilder &builder, Value memref, ValueRange ivs) { return create(builder, builder.getLoc(), std::forward(memref), std::forward(ivs)); } ::llvm::LogicalResult GenericAtomicRMWOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps3(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((std::equal_to<>()(::llvm::cast((*this->getODSOperands(0).begin()).getType()).getElementType(), (*this->getODSResults(0).begin()).getType())))) return emitOpError("failed to verify that result type matches element type of memref"); { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_MemRefOps1(*this, region, "atomic_body", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult GenericAtomicRMWOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult GenericAtomicRMWOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = ::llvm::cast(operands[0].getType()).getElementType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::llvm::LogicalResult GenericAtomicRMWOp::setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } // keep track of used keys in the input dictionary to be able to error out // if there are some unknown ones. ::mlir::DenseSet<::mlir::StringAttr> usedKeys; ::mlir::MLIRContext *ctx = dict.getContext(); (void)ctx; for (::mlir::NamedAttribute attr : dict) { if (!usedKeys.contains(attr.getName())) return emitError() << "unknown key '" << attr.getName() << "' when parsing properties dictionary"; } return ::mlir::success(); } void GenericAtomicRMWOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { { auto valueRange = getODSOperandIndexAndLength(0); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Read::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get()); } } { auto valueRange = getODSOperandIndexAndLength(0); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get()); } } } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::GenericAtomicRMWOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::LoadOp definitions //===----------------------------------------------------------------------===// namespace detail { LoadOpGenericAdaptorBase::LoadOpGenericAdaptorBase(LoadOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair LoadOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::BoolAttr LoadOpGenericAdaptorBase::getNontemporalAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().nontemporal); if (!attr) attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false); return attr; } bool LoadOpGenericAdaptorBase::getNontemporal() { auto attr = getNontemporalAttr(); if (!attr) return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue(); return attr.getValue(); } ::std::optional LoadOpGenericAdaptorBase::getAlignment() { auto attr = getAlignmentAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } } // namespace detail LoadOpAdaptor::LoadOpAdaptor(LoadOp op) : LoadOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult LoadOpAdaptor::verify(::mlir::Location loc) { auto tblgen_alignment = getProperties().alignment; (void)tblgen_alignment; auto tblgen_nontemporal = getProperties().nontemporal; (void)tblgen_nontemporal; if (tblgen_nontemporal && !((::llvm::isa<::mlir::BoolAttr>(tblgen_nontemporal)))) return emitError(loc, "'memref.load' op attribute 'nontemporal' failed to satisfy constraint: bool attribute"); if (tblgen_alignment && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_alignment))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getType().isSignlessInteger(64)))) && (((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getValue().isStrictlyPositive())) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getValue().isPowerOf2()))))) return emitError(loc, "'memref.load' op attribute 'alignment' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive and whose value is a power of two > 0"); return ::mlir::success(); } std::pair LoadOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange LoadOp::getIndicesMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult LoadOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.alignment; auto attr = dict.get("alignment"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `alignment` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.nontemporal; auto attr = dict.get("nontemporal"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `nontemporal` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute LoadOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.alignment; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("alignment", propStorage)); } { const auto &propStorage = prop.nontemporal; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("nontemporal", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code LoadOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.alignment.getAsOpaquePointer()), llvm::hash_value(prop.nontemporal.getAsOpaquePointer())); } std::optional LoadOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "alignment") return prop.alignment; if (name == "nontemporal") return prop.nontemporal; return std::nullopt; } void LoadOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "alignment") { prop.alignment = ::llvm::dyn_cast_or_null>(value); return; } if (name == "nontemporal") { prop.nontemporal = ::llvm::dyn_cast_or_null>(value); return; } } void LoadOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.alignment) attrs.append("alignment", prop.alignment); if (prop.nontemporal) attrs.append("nontemporal", prop.nontemporal); } ::llvm::LogicalResult LoadOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAlignmentAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps4(attr, "alignment", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNontemporalAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps3(attr, "nontemporal", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult LoadOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.alignment))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.nontemporal))) return ::mlir::failure(); return ::mlir::success(); } void LoadOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.alignment); writer.writeOptionalAttribute(prop.nontemporal); } bool LoadOp::getNontemporal() { auto attr = getNontemporalAttr(); if (!attr) return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue(); return attr.getValue(); } ::std::optional LoadOp::getAlignment() { auto attr = getAlignmentAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } void LoadOp::setNontemporal(::std::optional attrValue) { auto &odsProp = getProperties().nontemporal; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue); else odsProp = nullptr; } void LoadOp::setAlignment(::std::optional attrValue) { auto &odsProp = getProperties().alignment; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue); else odsProp = nullptr; } void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value memref, ValueRange indices, bool nontemporal, llvm::MaybeAlign alignment) { return build(odsBuilder, odsState, memref, indices, nontemporal, alignment ? odsBuilder.getI64IntegerAttr(alignment->value()) : nullptr); } LoadOp LoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value memref, ValueRange indices, bool nontemporal, llvm::MaybeAlign alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoadOp LoadOp::create(::mlir::ImplicitLocOpBuilder &builder, Value memref, ValueRange indices, bool nontemporal, llvm::MaybeAlign alignment) { return create(builder, builder.getLoc(), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); } void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value memref, ValueRange indices, bool nontemporal, llvm::MaybeAlign alignment) { return build(odsBuilder, odsState, resultType, memref, indices, nontemporal, alignment ? odsBuilder.getI64IntegerAttr(alignment->value()) : nullptr); } LoadOp LoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType, Value memref, ValueRange indices, bool nontemporal, llvm::MaybeAlign alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoadOp LoadOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType, Value memref, ValueRange indices, bool nontemporal, llvm::MaybeAlign alignment) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); } void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, Value memref, ValueRange indices, bool nontemporal, llvm::MaybeAlign alignment) { return build(odsBuilder, odsState, resultTypes, memref, indices, nontemporal, alignment ? odsBuilder.getI64IntegerAttr(alignment->value()) : nullptr); } LoadOp LoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, TypeRange resultTypes, Value memref, ValueRange indices, bool nontemporal, llvm::MaybeAlign alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoadOp LoadOp::create(::mlir::ImplicitLocOpBuilder &builder, TypeRange resultTypes, Value memref, ValueRange indices, bool nontemporal, llvm::MaybeAlign alignment) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); } void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/::mlir::BoolAttr nontemporal, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(memref); odsState.addOperands(indices); if (nontemporal) { odsState.getOrAddProperties().nontemporal = nontemporal; } if (alignment) { odsState.getOrAddProperties().alignment = alignment; } odsState.addTypes(result); } LoadOp LoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/::mlir::BoolAttr nontemporal, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoadOp LoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/::mlir::BoolAttr nontemporal, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(result), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); } void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/::mlir::BoolAttr nontemporal, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(memref); odsState.addOperands(indices); if (nontemporal) { odsState.getOrAddProperties().nontemporal = nontemporal; } if (alignment) { odsState.getOrAddProperties().alignment = alignment; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LoadOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } LoadOp LoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/::mlir::BoolAttr nontemporal, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoadOp LoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/::mlir::BoolAttr nontemporal, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); } void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/::mlir::BoolAttr nontemporal, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(memref); odsState.addOperands(indices); if (nontemporal) { odsState.getOrAddProperties().nontemporal = nontemporal; } if (alignment) { odsState.getOrAddProperties().alignment = alignment; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } LoadOp LoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/::mlir::BoolAttr nontemporal, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoadOp LoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/::mlir::BoolAttr nontemporal, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); } void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/bool nontemporal, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(memref); odsState.addOperands(indices); odsState.getOrAddProperties().nontemporal = odsBuilder.getBoolAttr(nontemporal); if (alignment) { odsState.getOrAddProperties().alignment = alignment; } odsState.addTypes(result); } LoadOp LoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/bool nontemporal, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoadOp LoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/bool nontemporal, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(result), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); } void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/bool nontemporal, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(memref); odsState.addOperands(indices); odsState.getOrAddProperties().nontemporal = odsBuilder.getBoolAttr(nontemporal); if (alignment) { odsState.getOrAddProperties().alignment = alignment; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LoadOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } LoadOp LoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/bool nontemporal, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoadOp LoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/bool nontemporal, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); } void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/bool nontemporal, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(memref); odsState.addOperands(indices); odsState.getOrAddProperties().nontemporal = odsBuilder.getBoolAttr(nontemporal); if (alignment) { odsState.getOrAddProperties().alignment = alignment; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } LoadOp LoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/bool nontemporal, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoadOp LoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/bool nontemporal, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); } void LoadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } LoadOp LoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoadOp LoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LoadOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LoadOp LoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoadOp LoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void LoadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } LoadOp LoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoadOp LoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(LoadOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } LoadOp LoadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoadOp LoadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult LoadOp::verifyInvariantsImpl() { auto tblgen_alignment = getProperties().alignment; (void)tblgen_alignment; auto tblgen_nontemporal = getProperties().nontemporal; (void)tblgen_nontemporal; if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps3(*this, tblgen_nontemporal, "nontemporal"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps4(*this, tblgen_alignment, "alignment"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps5(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((std::equal_to<>()(::llvm::cast((*this->getODSOperands(0).begin()).getType()).getElementType(), (*this->getODSResults(0).begin()).getType())))) return emitOpError("failed to verify that result type matches element type of 'memref'"); return ::mlir::success(); } ::llvm::LogicalResult LoadOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult LoadOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); if (operands.size() <= 0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = ::llvm::cast(operands[0].getType()).getElementType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult LoadOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand memrefRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> memrefOperands(&memrefRawOperand, 1); ::llvm::SMLoc memrefOperandsLoc; (void)memrefOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands; ::llvm::SMLoc indicesOperandsLoc; (void)indicesOperandsLoc; ::mlir::Type memrefRawType{}; ::llvm::ArrayRef<::mlir::Type> memrefTypes(&memrefRawType, 1); memrefOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(memrefRawOperand)) return ::mlir::failure(); if (parser.parseLSquare()) return ::mlir::failure(); indicesOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(indicesOperands)) return ::mlir::failure(); if (parser.parseRSquare()) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); memrefRawType = type; } for (::mlir::Type type : memrefTypes) { (void)type; if (!(((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { return parser.emitError(parser.getNameLoc()) << "'memref' must be memref of any non-token type values, but got " << type; } } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); result.addTypes(::llvm::cast(memrefTypes[0]).getElementType()); if (parser.resolveOperands(memrefOperands, memrefTypes, memrefOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void LoadOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getMemref(); _odsPrinter << "["; _odsPrinter << getIndices(); _odsPrinter << "]"; ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getNontemporalAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("nontemporal"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getMemref().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void LoadOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { { auto valueRange = getODSOperandIndexAndLength(0); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Read::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get()); } } } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::LoadOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::detail::LoadOpGenericAdaptorBase::Properties) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::AllocOp definitions //===----------------------------------------------------------------------===// namespace detail { AllocOpGenericAdaptorBase::AllocOpGenericAdaptorBase(AllocOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair AllocOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::std::optional AllocOpGenericAdaptorBase::getAlignment() { auto attr = getAlignmentAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } } // namespace detail AllocOpAdaptor::AllocOpAdaptor(AllocOp op) : AllocOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AllocOpAdaptor::verify(::mlir::Location loc) { auto tblgen_alignment = getProperties().alignment; (void)tblgen_alignment; if (tblgen_alignment && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_alignment))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getType().isSignlessInteger(64)))) && (((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getValue().isStrictlyPositive())) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getValue().isPowerOf2()))))) return emitError(loc, "'memref.alloc' op attribute 'alignment' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive and whose value is a power of two > 0"); return ::mlir::success(); } std::pair AllocOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange AllocOp::getDynamicSizesMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange AllocOp::getSymbolOperandsMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult AllocOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.alignment; auto attr = dict.get("alignment"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `alignment` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute AllocOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.alignment; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("alignment", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code AllocOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.alignment.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional AllocOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "alignment") return prop.alignment; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void AllocOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "alignment") { prop.alignment = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void AllocOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.alignment) attrs.append("alignment", prop.alignment); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult AllocOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAlignmentAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps4(attr, "alignment", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult AllocOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.alignment))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void AllocOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.alignment); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::std::optional AllocOp::getAlignment() { auto attr = getAlignmentAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } void AllocOp::setAlignment(::std::optional attrValue) { auto &odsProp = getProperties().alignment; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue); else odsProp = nullptr; } void AllocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, MemRefType memrefType, IntegerAttr alignment) { return build(odsBuilder, odsState, memrefType, {}, alignment); } AllocOp AllocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, MemRefType memrefType, IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memrefType), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocOp AllocOp::create(::mlir::ImplicitLocOpBuilder &builder, MemRefType memrefType, IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(memrefType), std::forward(alignment)); } void AllocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, MemRefType memrefType, ValueRange dynamicSizes, IntegerAttr alignment) { return build(odsBuilder, odsState, memrefType, dynamicSizes, {}, alignment); } AllocOp AllocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, MemRefType memrefType, ValueRange dynamicSizes, IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memrefType), std::forward(dynamicSizes), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocOp AllocOp::create(::mlir::ImplicitLocOpBuilder &builder, MemRefType memrefType, ValueRange dynamicSizes, IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(memrefType), std::forward(dynamicSizes), std::forward(alignment)); } void AllocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, MemRefType memrefType, ValueRange dynamicSizes, ValueRange symbolOperands, IntegerAttr alignment) { odsState.types.push_back(memrefType); odsState.addOperands(dynamicSizes); odsState.addOperands(symbolOperands); odsState.addAttribute(getOperandSegmentSizeAttr(), odsBuilder.getDenseI32ArrayAttr({ static_cast(dynamicSizes.size()), static_cast(symbolOperands.size())})); if (alignment) odsState.addAttribute(getAlignmentAttrStrName(), alignment); } AllocOp AllocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, MemRefType memrefType, ValueRange dynamicSizes, ValueRange symbolOperands, IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memrefType), std::forward(dynamicSizes), std::forward(symbolOperands), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocOp AllocOp::create(::mlir::ImplicitLocOpBuilder &builder, MemRefType memrefType, ValueRange dynamicSizes, ValueRange symbolOperands, IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(memrefType), std::forward(dynamicSizes), std::forward(symbolOperands), std::forward(alignment)); } void AllocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ArrayRef sizes, Type elementType, Attribute memorySpace) { SmallVector staticShape; SmallVector dynamicSizes; dispatchIndexOpFoldResults(sizes, dynamicSizes, staticShape); MemRefLayoutAttrInterface layout; MemRefType memrefType = MemRefType::get(staticShape, elementType, layout, memorySpace); return build(odsBuilder, odsState, memrefType, dynamicSizes); } AllocOp AllocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ArrayRef sizes, Type elementType, Attribute memorySpace) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sizes), std::forward(elementType), std::forward(memorySpace)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocOp AllocOp::create(::mlir::ImplicitLocOpBuilder &builder, ArrayRef sizes, Type elementType, Attribute memorySpace) { return create(builder, builder.getLoc(), std::forward(sizes), std::forward(elementType), std::forward(memorySpace)); } void AllocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type memref, ::mlir::ValueRange dynamicSizes, ::mlir::ValueRange symbolOperands, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(dynamicSizes); odsState.addOperands(symbolOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(dynamicSizes.size()), static_cast(symbolOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (alignment) { odsState.getOrAddProperties().alignment = alignment; } odsState.addTypes(memref); } AllocOp AllocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type memref, ::mlir::ValueRange dynamicSizes, ::mlir::ValueRange symbolOperands, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memref), std::forward(dynamicSizes), std::forward(symbolOperands), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocOp AllocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type memref, ::mlir::ValueRange dynamicSizes, ::mlir::ValueRange symbolOperands, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(memref), std::forward(dynamicSizes), std::forward(symbolOperands), std::forward(alignment)); } void AllocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dynamicSizes, ::mlir::ValueRange symbolOperands, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(dynamicSizes); odsState.addOperands(symbolOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(dynamicSizes.size()), static_cast(symbolOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (alignment) { odsState.getOrAddProperties().alignment = alignment; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AllocOp AllocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dynamicSizes, ::mlir::ValueRange symbolOperands, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(dynamicSizes), std::forward(symbolOperands), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocOp AllocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dynamicSizes, ::mlir::ValueRange symbolOperands, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(dynamicSizes), std::forward(symbolOperands), std::forward(alignment)); } void AllocOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } AllocOp AllocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocOp AllocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void AllocOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AllocOp AllocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocOp AllocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult AllocOp::verifyInvariantsImpl() { auto tblgen_alignment = getProperties().alignment; (void)tblgen_alignment; if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps4(*this, tblgen_alignment, "alignment"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult AllocOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult AllocOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dynamicSizesOperands; ::llvm::SMLoc dynamicSizesOperandsLoc; (void)dynamicSizesOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> symbolOperandsOperands; ::llvm::SMLoc symbolOperandsOperandsLoc; (void)symbolOperandsOperandsLoc; ::mlir::Type memrefRawType{}; ::llvm::ArrayRef<::mlir::Type> memrefTypes(&memrefRawType, 1); if (parser.parseLParen()) return ::mlir::failure(); dynamicSizesOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(dynamicSizesOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalLSquare())) { symbolOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(symbolOperandsOperands)) return ::mlir::failure(); if (parser.parseRSquare()) return ::mlir::failure(); } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); memrefRawType = type; } ::llvm::copy(::llvm::ArrayRef({static_cast(dynamicSizesOperands.size()), static_cast(symbolOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); result.addTypes(memrefTypes); if (parser.resolveOperands(dynamicSizesOperands, odsBuildableType0, dynamicSizesOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(symbolOperandsOperands, odsBuildableType0, symbolOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void AllocOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << "("; _odsPrinter << getDynamicSizes(); _odsPrinter << ")"; if (!getSymbolOperands().empty()) { _odsPrinter << "["; _odsPrinter << getSymbolOperands(); _odsPrinter << "]"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getMemref().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void AllocOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { { auto valueRange = getODSResultIndexAndLength(0); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Allocate::get(), getOperation()->getOpResult(idx), 0, true, ::mlir::SideEffects::DefaultResource::get()); } } } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::AllocOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::detail::AllocOpGenericAdaptorBase::Properties) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::AllocaOp definitions //===----------------------------------------------------------------------===// namespace detail { AllocaOpGenericAdaptorBase::AllocaOpGenericAdaptorBase(AllocaOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair AllocaOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::std::optional AllocaOpGenericAdaptorBase::getAlignment() { auto attr = getAlignmentAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } } // namespace detail AllocaOpAdaptor::AllocaOpAdaptor(AllocaOp op) : AllocaOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AllocaOpAdaptor::verify(::mlir::Location loc) { auto tblgen_alignment = getProperties().alignment; (void)tblgen_alignment; if (tblgen_alignment && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_alignment))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getType().isSignlessInteger(64)))) && (((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getValue().isStrictlyPositive())) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getValue().isPowerOf2()))))) return emitError(loc, "'memref.alloca' op attribute 'alignment' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive and whose value is a power of two > 0"); return ::mlir::success(); } std::pair AllocaOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange AllocaOp::getDynamicSizesMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange AllocaOp::getSymbolOperandsMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult AllocaOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.alignment; auto attr = dict.get("alignment"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `alignment` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute AllocaOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.alignment; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("alignment", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code AllocaOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.alignment.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional AllocaOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "alignment") return prop.alignment; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void AllocaOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "alignment") { prop.alignment = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void AllocaOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.alignment) attrs.append("alignment", prop.alignment); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult AllocaOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAlignmentAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps4(attr, "alignment", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult AllocaOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.alignment))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void AllocaOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.alignment); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::std::optional AllocaOp::getAlignment() { auto attr = getAlignmentAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } void AllocaOp::setAlignment(::std::optional attrValue) { auto &odsProp = getProperties().alignment; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue); else odsProp = nullptr; } void AllocaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, MemRefType memrefType, IntegerAttr alignment) { return build(odsBuilder, odsState, memrefType, {}, alignment); } AllocaOp AllocaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, MemRefType memrefType, IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memrefType), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocaOp AllocaOp::create(::mlir::ImplicitLocOpBuilder &builder, MemRefType memrefType, IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(memrefType), std::forward(alignment)); } void AllocaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, MemRefType memrefType, ValueRange dynamicSizes, IntegerAttr alignment) { return build(odsBuilder, odsState, memrefType, dynamicSizes, {}, alignment); } AllocaOp AllocaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, MemRefType memrefType, ValueRange dynamicSizes, IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memrefType), std::forward(dynamicSizes), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocaOp AllocaOp::create(::mlir::ImplicitLocOpBuilder &builder, MemRefType memrefType, ValueRange dynamicSizes, IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(memrefType), std::forward(dynamicSizes), std::forward(alignment)); } void AllocaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, MemRefType memrefType, ValueRange dynamicSizes, ValueRange symbolOperands, IntegerAttr alignment) { odsState.types.push_back(memrefType); odsState.addOperands(dynamicSizes); odsState.addOperands(symbolOperands); odsState.addAttribute(getOperandSegmentSizeAttr(), odsBuilder.getDenseI32ArrayAttr({ static_cast(dynamicSizes.size()), static_cast(symbolOperands.size())})); if (alignment) odsState.addAttribute(getAlignmentAttrStrName(), alignment); } AllocaOp AllocaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, MemRefType memrefType, ValueRange dynamicSizes, ValueRange symbolOperands, IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memrefType), std::forward(dynamicSizes), std::forward(symbolOperands), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocaOp AllocaOp::create(::mlir::ImplicitLocOpBuilder &builder, MemRefType memrefType, ValueRange dynamicSizes, ValueRange symbolOperands, IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(memrefType), std::forward(dynamicSizes), std::forward(symbolOperands), std::forward(alignment)); } void AllocaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ArrayRef sizes, Type elementType, Attribute memorySpace) { SmallVector staticShape; SmallVector dynamicSizes; dispatchIndexOpFoldResults(sizes, dynamicSizes, staticShape); MemRefLayoutAttrInterface layout; MemRefType memrefType = MemRefType::get(staticShape, elementType, layout, memorySpace); return build(odsBuilder, odsState, memrefType, dynamicSizes); } AllocaOp AllocaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ArrayRef sizes, Type elementType, Attribute memorySpace) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sizes), std::forward(elementType), std::forward(memorySpace)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocaOp AllocaOp::create(::mlir::ImplicitLocOpBuilder &builder, ArrayRef sizes, Type elementType, Attribute memorySpace) { return create(builder, builder.getLoc(), std::forward(sizes), std::forward(elementType), std::forward(memorySpace)); } void AllocaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type memref, ::mlir::ValueRange dynamicSizes, ::mlir::ValueRange symbolOperands, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(dynamicSizes); odsState.addOperands(symbolOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(dynamicSizes.size()), static_cast(symbolOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (alignment) { odsState.getOrAddProperties().alignment = alignment; } odsState.addTypes(memref); } AllocaOp AllocaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type memref, ::mlir::ValueRange dynamicSizes, ::mlir::ValueRange symbolOperands, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memref), std::forward(dynamicSizes), std::forward(symbolOperands), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocaOp AllocaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type memref, ::mlir::ValueRange dynamicSizes, ::mlir::ValueRange symbolOperands, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(memref), std::forward(dynamicSizes), std::forward(symbolOperands), std::forward(alignment)); } void AllocaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dynamicSizes, ::mlir::ValueRange symbolOperands, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(dynamicSizes); odsState.addOperands(symbolOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(dynamicSizes.size()), static_cast(symbolOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (alignment) { odsState.getOrAddProperties().alignment = alignment; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AllocaOp AllocaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dynamicSizes, ::mlir::ValueRange symbolOperands, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(dynamicSizes), std::forward(symbolOperands), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocaOp AllocaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dynamicSizes, ::mlir::ValueRange symbolOperands, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(dynamicSizes), std::forward(symbolOperands), std::forward(alignment)); } void AllocaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } AllocaOp AllocaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocaOp AllocaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void AllocaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AllocaOp AllocaOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocaOp AllocaOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult AllocaOp::verifyInvariantsImpl() { auto tblgen_alignment = getProperties().alignment; (void)tblgen_alignment; if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps4(*this, tblgen_alignment, "alignment"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult AllocaOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult AllocaOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dynamicSizesOperands; ::llvm::SMLoc dynamicSizesOperandsLoc; (void)dynamicSizesOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> symbolOperandsOperands; ::llvm::SMLoc symbolOperandsOperandsLoc; (void)symbolOperandsOperandsLoc; ::mlir::Type memrefRawType{}; ::llvm::ArrayRef<::mlir::Type> memrefTypes(&memrefRawType, 1); if (parser.parseLParen()) return ::mlir::failure(); dynamicSizesOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(dynamicSizesOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalLSquare())) { symbolOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(symbolOperandsOperands)) return ::mlir::failure(); if (parser.parseRSquare()) return ::mlir::failure(); } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); memrefRawType = type; } ::llvm::copy(::llvm::ArrayRef({static_cast(dynamicSizesOperands.size()), static_cast(symbolOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); result.addTypes(memrefTypes); if (parser.resolveOperands(dynamicSizesOperands, odsBuildableType0, dynamicSizesOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(symbolOperandsOperands, odsBuildableType0, symbolOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void AllocaOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << "("; _odsPrinter << getDynamicSizes(); _odsPrinter << ")"; if (!getSymbolOperands().empty()) { _odsPrinter << "["; _odsPrinter << getSymbolOperands(); _odsPrinter << "]"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getMemref().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void AllocaOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { { auto valueRange = getODSResultIndexAndLength(0); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Allocate::get(), getOperation()->getOpResult(idx), 0, true, ::mlir::SideEffects::AutomaticAllocationScopeResource::get()); } } } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::AllocaOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::detail::AllocaOpGenericAdaptorBase::Properties) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::AllocaScopeOp definitions //===----------------------------------------------------------------------===// namespace detail { AllocaScopeOpGenericAdaptorBase::AllocaScopeOpGenericAdaptorBase(AllocaScopeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail AllocaScopeOpAdaptor::AllocaScopeOpAdaptor(AllocaScopeOp op) : AllocaScopeOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AllocaScopeOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair AllocaScopeOp::getODSResultIndexAndLength(unsigned index) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumResults() - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::llvm::LogicalResult AllocaScopeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute AllocaScopeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code AllocaScopeOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional AllocaScopeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void AllocaScopeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void AllocaScopeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult AllocaScopeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void AllocaScopeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results) { (void)odsState.addRegion(); odsState.addTypes(results); } AllocaScopeOp AllocaScopeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange results) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(results)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocaScopeOp AllocaScopeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange results) { return create(builder, builder.getLoc(), std::forward(results)); } void AllocaScopeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); odsState.addTypes(resultTypes); } AllocaScopeOp AllocaScopeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocaScopeOp AllocaScopeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void AllocaScopeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); odsState.addTypes(resultTypes); } AllocaScopeOp AllocaScopeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocaScopeOp AllocaScopeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult AllocaScopeOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps8(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_MemRefOps2(*this, region, "bodyRegion", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult AllocaScopeOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult AllocaScopeOp::setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } // keep track of used keys in the input dictionary to be able to error out // if there are some unknown ones. ::mlir::DenseSet<::mlir::StringAttr> usedKeys; ::mlir::MLIRContext *ctx = dict.getContext(); (void)ctx; for (::mlir::NamedAttribute attr : dict) { if (!usedKeys.contains(attr.getName())) return emitError() << "unknown key '" << attr.getName() << "' when parsing properties dictionary"; } return ::mlir::success(); } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::AllocaScopeOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::AllocaScopeReturnOp definitions //===----------------------------------------------------------------------===// namespace detail { AllocaScopeReturnOpGenericAdaptorBase::AllocaScopeReturnOpGenericAdaptorBase(AllocaScopeReturnOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair AllocaScopeReturnOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } } // namespace detail AllocaScopeReturnOpAdaptor::AllocaScopeReturnOpAdaptor(AllocaScopeReturnOp op) : AllocaScopeReturnOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AllocaScopeReturnOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair AllocaScopeReturnOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange AllocaScopeReturnOp::getResultsMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult AllocaScopeReturnOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute AllocaScopeReturnOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code AllocaScopeReturnOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional AllocaScopeReturnOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void AllocaScopeReturnOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void AllocaScopeReturnOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult AllocaScopeReturnOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void AllocaScopeReturnOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { /*nothing to do */ } AllocaScopeReturnOp AllocaScopeReturnOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocaScopeReturnOp AllocaScopeReturnOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void AllocaScopeReturnOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange results) { odsState.addOperands(results); } AllocaScopeReturnOp AllocaScopeReturnOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange results) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(results)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocaScopeReturnOp AllocaScopeReturnOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange results) { return create(builder, builder.getLoc(), std::forward(results)); } void AllocaScopeReturnOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AllocaScopeReturnOp AllocaScopeReturnOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocaScopeReturnOp AllocaScopeReturnOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void AllocaScopeReturnOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AllocaScopeReturnOp AllocaScopeReturnOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AllocaScopeReturnOp AllocaScopeReturnOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult AllocaScopeReturnOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps8(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult AllocaScopeReturnOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult AllocaScopeReturnOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> resultsOperands; ::llvm::SMLoc resultsOperandsLoc; (void)resultsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> resultsTypes; { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } resultsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(resultsOperands)) return ::mlir::failure(); if (!resultsOperands.empty()) { if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(resultsTypes)) return ::mlir::failure(); } if (parser.resolveOperands(resultsOperands, resultsTypes, resultsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void AllocaScopeReturnOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); if (!getResults().empty()) { _odsPrinter << ' '; _odsPrinter << getResults(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getResults().getTypes(); } } void AllocaScopeReturnOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::AllocaScopeReturnOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::CastOp definitions //===----------------------------------------------------------------------===// namespace detail { CastOpGenericAdaptorBase::CastOpGenericAdaptorBase(CastOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail CastOpAdaptor::CastOpAdaptor(CastOp op) : CastOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CastOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult CastOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute CastOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code CastOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional CastOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void CastOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void CastOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult CastOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void CastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::Value source) { odsState.addOperands(source); odsState.addTypes(dest); } CastOp CastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dest, ::mlir::Value source) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dest), std::forward(source)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CastOp CastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dest, ::mlir::Value source) { return create(builder, builder.getLoc(), std::forward(dest), std::forward(source)); } void CastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source) { odsState.addOperands(source); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CastOp CastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(source)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CastOp CastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(source)); } void CastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CastOp CastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CastOp CastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CastOp CastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CastOp CastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult CastOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps6(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CastOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult CastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(&sourceRawOperand, 1); ::llvm::SMLoc sourceOperandsLoc; (void)sourceOperandsLoc; ::mlir::Type sourceRawType{}; ::llvm::ArrayRef<::mlir::Type> sourceTypes(&sourceRawType, 1); ::mlir::Type destRawType{}; ::llvm::ArrayRef<::mlir::Type> destTypes(&destRawType, 1); sourceOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sourceRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::BaseMemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); sourceRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::BaseMemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); destRawType = type; } result.addTypes(destTypes); if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void CastOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSource(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSource().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::BaseMemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getDest().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::BaseMemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void CastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::CastOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::CollapseShapeOp definitions //===----------------------------------------------------------------------===// namespace detail { CollapseShapeOpGenericAdaptorBase::CollapseShapeOpGenericAdaptorBase(CollapseShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::ArrayAttr CollapseShapeOpGenericAdaptorBase::getReassociation() { auto attr = getReassociationAttr(); return attr; } } // namespace detail CollapseShapeOpAdaptor::CollapseShapeOpAdaptor(CollapseShapeOp op) : CollapseShapeOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CollapseShapeOpAdaptor::verify(::mlir::Location loc) { auto tblgen_reassociation = getProperties().reassociation; (void)tblgen_reassociation; if (!tblgen_reassociation) return emitError(loc, "'memref.collapse_shape' op requires attribute 'reassociation'"); if (tblgen_reassociation && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_reassociation))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_reassociation), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); }))); })))) return emitError(loc, "'memref.collapse_shape' op attribute 'reassociation' failed to satisfy constraint: Array of 64-bit integer array attributes"); return ::mlir::success(); } ::llvm::LogicalResult CollapseShapeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.reassociation; auto attr = dict.get("reassociation"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `reassociation` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute CollapseShapeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.reassociation; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("reassociation", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code CollapseShapeOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.reassociation.getAsOpaquePointer())); } std::optional CollapseShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "reassociation") return prop.reassociation; return std::nullopt; } void CollapseShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "reassociation") { prop.reassociation = ::llvm::dyn_cast_or_null>(value); return; } } void CollapseShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.reassociation) attrs.append("reassociation", prop.reassociation); } ::llvm::LogicalResult CollapseShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReassociationAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps5(attr, "reassociation", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CollapseShapeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.reassociation))) return ::mlir::failure(); return ::mlir::success(); } void CollapseShapeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.reassociation); } ::mlir::ArrayAttr CollapseShapeOp::getReassociation() { auto attr = getReassociationAttr(); return attr; } CollapseShapeOp CollapseShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value src, ArrayRef reassociation, ArrayRef attrs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(reassociation), std::forward(attrs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CollapseShapeOp CollapseShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, Value src, ArrayRef reassociation, ArrayRef attrs) { return create(builder, builder.getLoc(), std::forward(src), std::forward(reassociation), std::forward(attrs)); } void CollapseShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value src, ArrayRef reassociation, ArrayRef attrs) { auto reassociationMaps = convertReassociationMapsToIndices(reassociation); build(odsBuilder, odsState, src, reassociationMaps, attrs); } CollapseShapeOp CollapseShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value src, ArrayRef reassociation, ArrayRef attrs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(src), std::forward(reassociation), std::forward(attrs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CollapseShapeOp CollapseShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, Value src, ArrayRef reassociation, ArrayRef attrs) { return create(builder, builder.getLoc(), std::forward(src), std::forward(reassociation), std::forward(attrs)); } void CollapseShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value src, ArrayRef reassociation, ArrayRef attrs) { odsState.addAttribute("reassociation", getReassociationIndicesAttribute(odsBuilder, reassociation)); build(odsBuilder, odsState, resultType, src, attrs); } CollapseShapeOp CollapseShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType, Value src, ArrayRef reassociation, ArrayRef attrs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(src), std::forward(reassociation), std::forward(attrs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CollapseShapeOp CollapseShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType, Value src, ArrayRef reassociation, ArrayRef attrs) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(src), std::forward(reassociation), std::forward(attrs)); } void CollapseShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value src, ArrayRef reassociation, ArrayRef attrs) { auto reassociationMaps = convertReassociationMapsToIndices(reassociation); build(odsBuilder, odsState, resultType, src, reassociationMaps, attrs); } CollapseShapeOp CollapseShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType, Value src, ArrayRef reassociation, ArrayRef attrs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(src), std::forward(reassociation), std::forward(attrs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CollapseShapeOp CollapseShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType, Value src, ArrayRef reassociation, ArrayRef attrs) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(src), std::forward(reassociation), std::forward(attrs)); } void CollapseShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value src, ::mlir::ArrayAttr reassociation) { odsState.addOperands(src); odsState.getOrAddProperties().reassociation = reassociation; odsState.addTypes(result); } CollapseShapeOp CollapseShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value src, ::mlir::ArrayAttr reassociation) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(src), std::forward(reassociation)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CollapseShapeOp CollapseShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value src, ::mlir::ArrayAttr reassociation) { return create(builder, builder.getLoc(), std::forward(result), std::forward(src), std::forward(reassociation)); } void CollapseShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::ArrayAttr reassociation) { odsState.addOperands(src); odsState.getOrAddProperties().reassociation = reassociation; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CollapseShapeOp CollapseShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::ArrayAttr reassociation) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(reassociation)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CollapseShapeOp CollapseShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::ArrayAttr reassociation) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(reassociation)); } void CollapseShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } CollapseShapeOp CollapseShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CollapseShapeOp CollapseShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void CollapseShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CollapseShapeOp CollapseShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CollapseShapeOp CollapseShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult CollapseShapeOp::verifyInvariantsImpl() { auto tblgen_reassociation = getProperties().reassociation; (void)tblgen_reassociation; if (!tblgen_reassociation) return emitOpError("requires attribute 'reassociation'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps5(*this, tblgen_reassociation, "reassociation"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps9(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps9(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CollapseShapeOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult CollapseShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::ArrayAttr reassociationAttr; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(reassociationAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (reassociationAttr) result.getOrAddProperties().reassociation = reassociationAttr; { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseKeyword("into")) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resultRawType = type; } result.addTypes(resultTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void CollapseShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getReassociationAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("reassociation"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "into"; _odsPrinter << ' '; { auto type = getResult().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void CollapseShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::CollapseShapeOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::detail::CollapseShapeOpGenericAdaptorBase::Properties) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::DeallocOp definitions //===----------------------------------------------------------------------===// namespace detail { DeallocOpGenericAdaptorBase::DeallocOpGenericAdaptorBase(DeallocOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail DeallocOpAdaptor::DeallocOpAdaptor(DeallocOp op) : DeallocOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DeallocOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult DeallocOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute DeallocOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DeallocOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional DeallocOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void DeallocOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void DeallocOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult DeallocOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void DeallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value memref) { odsState.addOperands(memref); } DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value memref) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memref)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value memref) { return create(builder, builder.getLoc(), std::forward(memref)); } void DeallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value memref) { odsState.addOperands(memref); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value memref) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(memref)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value memref) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(memref)); } void DeallocOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void DeallocOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult DeallocOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DeallocOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult DeallocOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand memrefRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> memrefOperands(&memrefRawOperand, 1); ::llvm::SMLoc memrefOperandsLoc; (void)memrefOperandsLoc; ::mlir::Type memrefRawType{}; ::llvm::ArrayRef<::mlir::Type> memrefTypes(&memrefRawType, 1); memrefOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(memrefRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::BaseMemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); memrefRawType = type; } if (parser.resolveOperands(memrefOperands, memrefTypes, memrefOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DeallocOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getMemref(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getMemref().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::BaseMemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void DeallocOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { { auto valueRange = getODSOperandIndexAndLength(0); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Free::get(), &getOperation()->getOpOperand(idx), 0, true, ::mlir::SideEffects::DefaultResource::get()); } } } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::DeallocOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::DimOp definitions //===----------------------------------------------------------------------===// namespace detail { DimOpGenericAdaptorBase::DimOpGenericAdaptorBase(DimOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail DimOpAdaptor::DimOpAdaptor(DimOp op) : DimOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DimOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult DimOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute DimOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DimOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional DimOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void DimOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void DimOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult DimOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } DimOp DimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value source, int64_t index) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(source), std::forward(index)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DimOp DimOp::create(::mlir::ImplicitLocOpBuilder &builder, Value source, int64_t index) { return create(builder, builder.getLoc(), std::forward(source), std::forward(index)); } void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value index) { odsState.addOperands(source); odsState.addOperands(index); odsState.addTypes(result); } DimOp DimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value source, ::mlir::Value index) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(source), std::forward(index)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DimOp DimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value source, ::mlir::Value index) { return create(builder, builder.getLoc(), std::forward(result), std::forward(source), std::forward(index)); } void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value index) { odsState.addOperands(source); odsState.addOperands(index); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DimOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } DimOp DimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value source, ::mlir::Value index) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(source), std::forward(index)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DimOp DimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value source, ::mlir::Value index) { return create(builder, builder.getLoc(), std::forward(source), std::forward(index)); } void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value index) { odsState.addOperands(source); odsState.addOperands(index); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DimOp DimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value index) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(source), std::forward(index)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DimOp DimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value index) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(source), std::forward(index)); } void DimOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DimOp DimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DimOp DimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DimOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } DimOp DimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DimOp DimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void DimOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DimOp DimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DimOp DimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DimOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } DimOp DimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DimOp DimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult DimOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps10(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps11(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DimOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult DimOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult DimOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(&sourceRawOperand, 1); ::llvm::SMLoc sourceOperandsLoc; (void)sourceOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand indexRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> indexOperands(&indexRawOperand, 1); ::llvm::SMLoc indexOperandsLoc; (void)indexOperandsLoc; ::mlir::Type sourceRawType{}; ::llvm::ArrayRef<::mlir::Type> sourceTypes(&sourceRawType, 1); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } sourceOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sourceRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); indexOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(indexRawOperand)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); sourceRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); result.addTypes(odsBuildableType0); if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(indexOperands, odsBuildableType0, indexOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DimOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' '; _odsPrinter << getSource(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getIndex(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSource().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void DimOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::DimOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::DmaStartOp definitions //===----------------------------------------------------------------------===// namespace detail { DmaStartOpGenericAdaptorBase::DmaStartOpGenericAdaptorBase(DmaStartOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair DmaStartOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } } // namespace detail DmaStartOpAdaptor::DmaStartOpAdaptor(DmaStartOp op) : DmaStartOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DmaStartOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair DmaStartOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange DmaStartOp::getOperandsMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult DmaStartOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute DmaStartOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DmaStartOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional DmaStartOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void DmaStartOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void DmaStartOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult DmaStartOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } DmaStartOp DmaStartOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value srcMemRef, ValueRange srcIndices, Value destMemRef, ValueRange destIndices, Value numElements, Value tagMemRef, ValueRange tagIndices, Value stride, Value elementsPerStride) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(srcMemRef), std::forward(srcIndices), std::forward(destMemRef), std::forward(destIndices), std::forward(numElements), std::forward(tagMemRef), std::forward(tagIndices), std::forward(stride), std::forward(elementsPerStride)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DmaStartOp DmaStartOp::create(::mlir::ImplicitLocOpBuilder &builder, Value srcMemRef, ValueRange srcIndices, Value destMemRef, ValueRange destIndices, Value numElements, Value tagMemRef, ValueRange tagIndices, Value stride, Value elementsPerStride) { return create(builder, builder.getLoc(), std::forward(srcMemRef), std::forward(srcIndices), std::forward(destMemRef), std::forward(destIndices), std::forward(numElements), std::forward(tagMemRef), std::forward(tagIndices), std::forward(stride), std::forward(elementsPerStride)); } void DmaStartOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands) { odsState.addOperands(operands); } DmaStartOp DmaStartOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DmaStartOp DmaStartOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands) { return create(builder, builder.getLoc(), std::forward(operands)); } void DmaStartOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DmaStartOp DmaStartOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DmaStartOp DmaStartOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void DmaStartOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DmaStartOp DmaStartOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DmaStartOp DmaStartOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult DmaStartOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps8(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DmaStartOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult DmaStartOp::setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } // keep track of used keys in the input dictionary to be able to error out // if there are some unknown ones. ::mlir::DenseSet<::mlir::StringAttr> usedKeys; ::mlir::MLIRContext *ctx = dict.getContext(); (void)ctx; for (::mlir::NamedAttribute attr : dict) { if (!usedKeys.contains(attr.getName())) return emitError() << "unknown key '" << attr.getName() << "' when parsing properties dictionary"; } return ::mlir::success(); } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::DmaStartOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::DmaWaitOp definitions //===----------------------------------------------------------------------===// namespace detail { DmaWaitOpGenericAdaptorBase::DmaWaitOpGenericAdaptorBase(DmaWaitOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair DmaWaitOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true, false}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } } // namespace detail DmaWaitOpAdaptor::DmaWaitOpAdaptor(DmaWaitOp op) : DmaWaitOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DmaWaitOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair DmaWaitOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, true, false}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange DmaWaitOp::getTagIndicesMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult DmaWaitOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute DmaWaitOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DmaWaitOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional DmaWaitOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void DmaWaitOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void DmaWaitOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult DmaWaitOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void DmaWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tagMemRef, ::mlir::ValueRange tagIndices, ::mlir::Value numElements) { odsState.addOperands(tagMemRef); odsState.addOperands(tagIndices); odsState.addOperands(numElements); } DmaWaitOp DmaWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value tagMemRef, ::mlir::ValueRange tagIndices, ::mlir::Value numElements) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(tagMemRef), std::forward(tagIndices), std::forward(numElements)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DmaWaitOp DmaWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value tagMemRef, ::mlir::ValueRange tagIndices, ::mlir::Value numElements) { return create(builder, builder.getLoc(), std::forward(tagMemRef), std::forward(tagIndices), std::forward(numElements)); } void DmaWaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tagMemRef, ::mlir::ValueRange tagIndices, ::mlir::Value numElements) { odsState.addOperands(tagMemRef); odsState.addOperands(tagIndices); odsState.addOperands(numElements); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } DmaWaitOp DmaWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value tagMemRef, ::mlir::ValueRange tagIndices, ::mlir::Value numElements) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(tagMemRef), std::forward(tagIndices), std::forward(numElements)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DmaWaitOp DmaWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value tagMemRef, ::mlir::ValueRange tagIndices, ::mlir::Value numElements) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(tagMemRef), std::forward(tagIndices), std::forward(numElements)); } void DmaWaitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DmaWaitOp DmaWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DmaWaitOp DmaWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void DmaWaitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DmaWaitOp DmaWaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DmaWaitOp DmaWaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult DmaWaitOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DmaWaitOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult DmaWaitOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand tagMemRefRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tagMemRefOperands(&tagMemRefRawOperand, 1); ::llvm::SMLoc tagMemRefOperandsLoc; (void)tagMemRefOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> tagIndicesOperands; ::llvm::SMLoc tagIndicesOperandsLoc; (void)tagIndicesOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand numElementsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> numElementsOperands(&numElementsRawOperand, 1); ::llvm::SMLoc numElementsOperandsLoc; (void)numElementsOperandsLoc; ::mlir::Type tagMemRefRawType{}; ::llvm::ArrayRef<::mlir::Type> tagMemRefTypes(&tagMemRefRawType, 1); tagMemRefOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(tagMemRefRawOperand)) return ::mlir::failure(); if (parser.parseLSquare()) return ::mlir::failure(); tagIndicesOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(tagIndicesOperands)) return ::mlir::failure(); if (parser.parseRSquare()) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); numElementsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(numElementsRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); tagMemRefRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); if (parser.resolveOperands(tagMemRefOperands, tagMemRefTypes, tagMemRefOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(tagIndicesOperands, odsBuildableType0, tagIndicesOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(numElementsOperands, odsBuildableType0, numElementsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DmaWaitOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getTagMemRef(); _odsPrinter << "["; _odsPrinter << getTagIndices(); _odsPrinter << "]"; _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getNumElements(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getTagMemRef().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::DmaWaitOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::ExpandShapeOp definitions //===----------------------------------------------------------------------===// namespace detail { ExpandShapeOpGenericAdaptorBase::ExpandShapeOpGenericAdaptorBase(ExpandShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ExpandShapeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::ArrayAttr ExpandShapeOpGenericAdaptorBase::getReassociation() { auto attr = getReassociationAttr(); return attr; } ::llvm::ArrayRef ExpandShapeOpGenericAdaptorBase::getStaticOutputShape() { auto attr = getStaticOutputShapeAttr(); return attr; } } // namespace detail ExpandShapeOpAdaptor::ExpandShapeOpAdaptor(ExpandShapeOp op) : ExpandShapeOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ExpandShapeOpAdaptor::verify(::mlir::Location loc) { auto tblgen_reassociation = getProperties().reassociation; (void)tblgen_reassociation; if (!tblgen_reassociation) return emitError(loc, "'memref.expand_shape' op requires attribute 'reassociation'"); auto tblgen_static_output_shape = getProperties().static_output_shape; (void)tblgen_static_output_shape; if (!tblgen_static_output_shape) return emitError(loc, "'memref.expand_shape' op requires attribute 'static_output_shape'"); if (tblgen_reassociation && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_reassociation))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_reassociation), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); }))); })))) return emitError(loc, "'memref.expand_shape' op attribute 'reassociation' failed to satisfy constraint: Array of 64-bit integer array attributes"); if (tblgen_static_output_shape && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_output_shape)))) return emitError(loc, "'memref.expand_shape' op attribute 'static_output_shape' failed to satisfy constraint: i64 dense array attribute"); return ::mlir::success(); } std::pair ExpandShapeOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange ExpandShapeOp::getOutputShapeMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult ExpandShapeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.reassociation; auto attr = dict.get("reassociation"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `reassociation` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.static_output_shape; auto attr = dict.get("static_output_shape"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `static_output_shape` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ExpandShapeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.reassociation; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("reassociation", propStorage)); } { const auto &propStorage = prop.static_output_shape; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("static_output_shape", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ExpandShapeOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.reassociation.getAsOpaquePointer()), llvm::hash_value(prop.static_output_shape.getAsOpaquePointer())); } std::optional ExpandShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "reassociation") return prop.reassociation; if (name == "static_output_shape") return prop.static_output_shape; return std::nullopt; } void ExpandShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "reassociation") { prop.reassociation = ::llvm::dyn_cast_or_null>(value); return; } if (name == "static_output_shape") { prop.static_output_shape = ::llvm::dyn_cast_or_null>(value); return; } } void ExpandShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.reassociation) attrs.append("reassociation", prop.reassociation); if (prop.static_output_shape) attrs.append("static_output_shape", prop.static_output_shape); } ::llvm::LogicalResult ExpandShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReassociationAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps5(attr, "reassociation", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStaticOutputShapeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps6(attr, "static_output_shape", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ExpandShapeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.reassociation))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.static_output_shape))) return ::mlir::failure(); return ::mlir::success(); } void ExpandShapeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.reassociation); writer.writeAttribute(prop.static_output_shape); } ::mlir::ArrayAttr ExpandShapeOp::getReassociation() { auto attr = getReassociationAttr(); return attr; } ::llvm::ArrayRef ExpandShapeOp::getStaticOutputShape() { auto attr = getStaticOutputShapeAttr(); return attr; } void ExpandShapeOp::setStaticOutputShape(::llvm::ArrayRef attrValue) { getProperties().static_output_shape = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); } ExpandShapeOp ExpandShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType, Value src, ArrayRef reassociation, ArrayRef outputShape) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(src), std::forward(reassociation), std::forward(outputShape)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExpandShapeOp ExpandShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType, Value src, ArrayRef reassociation, ArrayRef outputShape) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(src), std::forward(reassociation), std::forward(outputShape)); } ExpandShapeOp ExpandShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType, Value src, ArrayRef reassociation) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(src), std::forward(reassociation)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExpandShapeOp ExpandShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType, Value src, ArrayRef reassociation) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(src), std::forward(reassociation)); } void ExpandShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value src, ArrayRef reassociation) { auto reassociationIndices = convertReassociationMapsToIndices(reassociation); build(odsBuilder, odsState, resultType, src, reassociationIndices); } ExpandShapeOp ExpandShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType, Value src, ArrayRef reassociation) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(src), std::forward(reassociation)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExpandShapeOp ExpandShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType, Value src, ArrayRef reassociation) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(src), std::forward(reassociation)); } void ExpandShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value src, ArrayRef reassociation, ArrayRef outputShape) { auto reassociationMaps = convertReassociationMapsToIndices(reassociation); build(odsBuilder, odsState, resultType, src, reassociationMaps, outputShape); } ExpandShapeOp ExpandShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type resultType, Value src, ArrayRef reassociation, ArrayRef outputShape) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(src), std::forward(reassociation), std::forward(outputShape)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExpandShapeOp ExpandShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, Type resultType, Value src, ArrayRef reassociation, ArrayRef outputShape) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(src), std::forward(reassociation), std::forward(outputShape)); } ExpandShapeOp ExpandShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ArrayRef resultShape, Value src, ArrayRef reassociation) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultShape), std::forward(src), std::forward(reassociation)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExpandShapeOp ExpandShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ArrayRef resultShape, Value src, ArrayRef reassociation) { return create(builder, builder.getLoc(), std::forward(resultShape), std::forward(src), std::forward(reassociation)); } ExpandShapeOp ExpandShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ArrayRef resultShape, Value src, ArrayRef reassociation, ArrayRef outputShape) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultShape), std::forward(src), std::forward(reassociation), std::forward(outputShape)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExpandShapeOp ExpandShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ArrayRef resultShape, Value src, ArrayRef reassociation, ArrayRef outputShape) { return create(builder, builder.getLoc(), std::forward(resultShape), std::forward(src), std::forward(reassociation), std::forward(outputShape)); } void ExpandShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value src, ::mlir::ArrayAttr reassociation, ::mlir::ValueRange output_shape, ::mlir::DenseI64ArrayAttr static_output_shape) { odsState.addOperands(src); odsState.addOperands(output_shape); odsState.getOrAddProperties().reassociation = reassociation; odsState.getOrAddProperties().static_output_shape = static_output_shape; odsState.addTypes(result); } ExpandShapeOp ExpandShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value src, ::mlir::ArrayAttr reassociation, ::mlir::ValueRange output_shape, ::mlir::DenseI64ArrayAttr static_output_shape) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(src), std::forward(reassociation), std::forward(output_shape), std::forward(static_output_shape)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExpandShapeOp ExpandShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value src, ::mlir::ArrayAttr reassociation, ::mlir::ValueRange output_shape, ::mlir::DenseI64ArrayAttr static_output_shape) { return create(builder, builder.getLoc(), std::forward(result), std::forward(src), std::forward(reassociation), std::forward(output_shape), std::forward(static_output_shape)); } void ExpandShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::ArrayAttr reassociation, ::mlir::ValueRange output_shape, ::mlir::DenseI64ArrayAttr static_output_shape) { odsState.addOperands(src); odsState.addOperands(output_shape); odsState.getOrAddProperties().reassociation = reassociation; odsState.getOrAddProperties().static_output_shape = static_output_shape; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ExpandShapeOp ExpandShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::ArrayAttr reassociation, ::mlir::ValueRange output_shape, ::mlir::DenseI64ArrayAttr static_output_shape) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(reassociation), std::forward(output_shape), std::forward(static_output_shape)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExpandShapeOp ExpandShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::ArrayAttr reassociation, ::mlir::ValueRange output_shape, ::mlir::DenseI64ArrayAttr static_output_shape) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(reassociation), std::forward(output_shape), std::forward(static_output_shape)); } void ExpandShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value src, ::mlir::ArrayAttr reassociation, ::mlir::ValueRange output_shape, ::llvm::ArrayRef static_output_shape) { odsState.addOperands(src); odsState.addOperands(output_shape); odsState.getOrAddProperties().reassociation = reassociation; odsState.getOrAddProperties().static_output_shape = odsBuilder.getDenseI64ArrayAttr(static_output_shape); odsState.addTypes(result); } ExpandShapeOp ExpandShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value src, ::mlir::ArrayAttr reassociation, ::mlir::ValueRange output_shape, ::llvm::ArrayRef static_output_shape) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(src), std::forward(reassociation), std::forward(output_shape), std::forward(static_output_shape)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExpandShapeOp ExpandShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value src, ::mlir::ArrayAttr reassociation, ::mlir::ValueRange output_shape, ::llvm::ArrayRef static_output_shape) { return create(builder, builder.getLoc(), std::forward(result), std::forward(src), std::forward(reassociation), std::forward(output_shape), std::forward(static_output_shape)); } void ExpandShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::ArrayAttr reassociation, ::mlir::ValueRange output_shape, ::llvm::ArrayRef static_output_shape) { odsState.addOperands(src); odsState.addOperands(output_shape); odsState.getOrAddProperties().reassociation = reassociation; odsState.getOrAddProperties().static_output_shape = odsBuilder.getDenseI64ArrayAttr(static_output_shape); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ExpandShapeOp ExpandShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::ArrayAttr reassociation, ::mlir::ValueRange output_shape, ::llvm::ArrayRef static_output_shape) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(src), std::forward(reassociation), std::forward(output_shape), std::forward(static_output_shape)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExpandShapeOp ExpandShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::ArrayAttr reassociation, ::mlir::ValueRange output_shape, ::llvm::ArrayRef static_output_shape) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(src), std::forward(reassociation), std::forward(output_shape), std::forward(static_output_shape)); } void ExpandShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ExpandShapeOp ExpandShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExpandShapeOp ExpandShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ExpandShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ExpandShapeOp ExpandShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExpandShapeOp ExpandShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ExpandShapeOp::verifyInvariantsImpl() { auto tblgen_reassociation = getProperties().reassociation; (void)tblgen_reassociation; if (!tblgen_reassociation) return emitOpError("requires attribute 'reassociation'"); auto tblgen_static_output_shape = getProperties().static_output_shape; (void)tblgen_static_output_shape; if (!tblgen_static_output_shape) return emitOpError("requires attribute 'static_output_shape'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps5(*this, tblgen_reassociation, "reassociation"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps6(*this, tblgen_static_output_shape, "static_output_shape"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps9(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps9(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ExpandShapeOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ExpandShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(&srcRawOperand, 1); ::llvm::SMLoc srcOperandsLoc; (void)srcOperandsLoc; ::mlir::ArrayAttr reassociationAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> output_shapeOperands; ::llvm::SMLoc output_shapeOperandsLoc; (void)output_shapeOperandsLoc; ::mlir::DenseI64ArrayAttr static_output_shapeAttr; ::mlir::Type srcRawType{}; ::llvm::ArrayRef<::mlir::Type> srcTypes(&srcRawType, 1); ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); srcOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcRawOperand)) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(reassociationAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (reassociationAttr) result.getOrAddProperties().reassociation = reassociationAttr; if (parser.parseKeyword("output_shape")) return ::mlir::failure(); { output_shapeOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDynamicIndexList(parser, output_shapeOperands, static_output_shapeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().static_output_shape = static_output_shapeAttr; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcRawType = type; } if (parser.parseKeyword("into")) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resultRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); result.addTypes(resultTypes); if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(output_shapeOperands, odsBuildableType0, output_shapeOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ExpandShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrc(); _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getReassociationAttr()); _odsPrinter << ' ' << "output_shape"; _odsPrinter << ' '; printDynamicIndexList(_odsPrinter, *this, getOutputShape(), getStaticOutputShapeAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("reassociation"); elidedAttrs.push_back("static_output_shape"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrc().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "into"; _odsPrinter << ' '; { auto type = getResult().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ExpandShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::ExpandShapeOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::detail::ExpandShapeOpGenericAdaptorBase::Properties) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::ExtractAlignedPointerAsIndexOp definitions //===----------------------------------------------------------------------===// namespace detail { ExtractAlignedPointerAsIndexOpGenericAdaptorBase::ExtractAlignedPointerAsIndexOpGenericAdaptorBase(ExtractAlignedPointerAsIndexOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail ExtractAlignedPointerAsIndexOpAdaptor::ExtractAlignedPointerAsIndexOpAdaptor(ExtractAlignedPointerAsIndexOp op) : ExtractAlignedPointerAsIndexOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ExtractAlignedPointerAsIndexOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult ExtractAlignedPointerAsIndexOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute ExtractAlignedPointerAsIndexOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ExtractAlignedPointerAsIndexOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional ExtractAlignedPointerAsIndexOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void ExtractAlignedPointerAsIndexOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void ExtractAlignedPointerAsIndexOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult ExtractAlignedPointerAsIndexOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void ExtractAlignedPointerAsIndexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type aligned_pointer, ::mlir::Value source) { odsState.addOperands(source); odsState.addTypes(aligned_pointer); } ExtractAlignedPointerAsIndexOp ExtractAlignedPointerAsIndexOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type aligned_pointer, ::mlir::Value source) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(aligned_pointer), std::forward(source)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtractAlignedPointerAsIndexOp ExtractAlignedPointerAsIndexOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type aligned_pointer, ::mlir::Value source) { return create(builder, builder.getLoc(), std::forward(aligned_pointer), std::forward(source)); } void ExtractAlignedPointerAsIndexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source) { odsState.addOperands(source); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ExtractAlignedPointerAsIndexOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ExtractAlignedPointerAsIndexOp ExtractAlignedPointerAsIndexOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value source) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(source)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtractAlignedPointerAsIndexOp ExtractAlignedPointerAsIndexOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value source) { return create(builder, builder.getLoc(), std::forward(source)); } void ExtractAlignedPointerAsIndexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source) { odsState.addOperands(source); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ExtractAlignedPointerAsIndexOp ExtractAlignedPointerAsIndexOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(source)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtractAlignedPointerAsIndexOp ExtractAlignedPointerAsIndexOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(source)); } void ExtractAlignedPointerAsIndexOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ExtractAlignedPointerAsIndexOp ExtractAlignedPointerAsIndexOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtractAlignedPointerAsIndexOp ExtractAlignedPointerAsIndexOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ExtractAlignedPointerAsIndexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ExtractAlignedPointerAsIndexOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ExtractAlignedPointerAsIndexOp ExtractAlignedPointerAsIndexOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtractAlignedPointerAsIndexOp ExtractAlignedPointerAsIndexOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ExtractAlignedPointerAsIndexOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ExtractAlignedPointerAsIndexOp ExtractAlignedPointerAsIndexOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtractAlignedPointerAsIndexOp ExtractAlignedPointerAsIndexOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ExtractAlignedPointerAsIndexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ExtractAlignedPointerAsIndexOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ExtractAlignedPointerAsIndexOp ExtractAlignedPointerAsIndexOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtractAlignedPointerAsIndexOp ExtractAlignedPointerAsIndexOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ExtractAlignedPointerAsIndexOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps11(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ExtractAlignedPointerAsIndexOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult ExtractAlignedPointerAsIndexOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ExtractAlignedPointerAsIndexOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(&sourceRawOperand, 1); ::llvm::SMLoc sourceOperandsLoc; (void)sourceOperandsLoc; ::mlir::Type sourceRawType{}; ::llvm::ArrayRef<::mlir::Type> sourceTypes(&sourceRawType, 1); ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; sourceOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sourceRawOperand)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); { ::mlir::BaseMemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); sourceRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); if (parser.parseTypeList(allResultTypes)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } result.addTypes(allResultTypes); if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ExtractAlignedPointerAsIndexOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSource(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSource().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::BaseMemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; _odsPrinter << getOperation()->getResultTypes(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } void ExtractAlignedPointerAsIndexOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::ExtractAlignedPointerAsIndexOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::ExtractStridedMetadataOp definitions //===----------------------------------------------------------------------===// namespace detail { ExtractStridedMetadataOpGenericAdaptorBase::ExtractStridedMetadataOpGenericAdaptorBase(ExtractStridedMetadataOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail ExtractStridedMetadataOpAdaptor::ExtractStridedMetadataOpAdaptor(ExtractStridedMetadataOp op) : ExtractStridedMetadataOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ExtractStridedMetadataOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair ExtractStridedMetadataOp::getODSResultIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, true, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumResults() - 2) / 2; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::llvm::LogicalResult ExtractStridedMetadataOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute ExtractStridedMetadataOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ExtractStridedMetadataOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional ExtractStridedMetadataOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void ExtractStridedMetadataOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void ExtractStridedMetadataOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult ExtractStridedMetadataOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void ExtractStridedMetadataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type base_buffer, ::mlir::Type offset, ::mlir::TypeRange sizes, ::mlir::TypeRange strides, ::mlir::Value source) { odsState.addOperands(source); odsState.addTypes(base_buffer); odsState.addTypes(offset); odsState.addTypes(sizes); odsState.addTypes(strides); } ExtractStridedMetadataOp ExtractStridedMetadataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type base_buffer, ::mlir::Type offset, ::mlir::TypeRange sizes, ::mlir::TypeRange strides, ::mlir::Value source) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(base_buffer), std::forward(offset), std::forward(sizes), std::forward(strides), std::forward(source)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtractStridedMetadataOp ExtractStridedMetadataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type base_buffer, ::mlir::Type offset, ::mlir::TypeRange sizes, ::mlir::TypeRange strides, ::mlir::Value source) { return create(builder, builder.getLoc(), std::forward(base_buffer), std::forward(offset), std::forward(sizes), std::forward(strides), std::forward(source)); } void ExtractStridedMetadataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source) { odsState.addOperands(source); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ExtractStridedMetadataOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } ExtractStridedMetadataOp ExtractStridedMetadataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value source) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(source)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtractStridedMetadataOp ExtractStridedMetadataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value source) { return create(builder, builder.getLoc(), std::forward(source)); } void ExtractStridedMetadataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source) { odsState.addOperands(source); assert(resultTypes.size() >= 2u && "mismatched number of results"); odsState.addTypes(resultTypes); } ExtractStridedMetadataOp ExtractStridedMetadataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(source)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtractStridedMetadataOp ExtractStridedMetadataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(source)); } void ExtractStridedMetadataOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() >= 2u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ExtractStridedMetadataOp ExtractStridedMetadataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtractStridedMetadataOp ExtractStridedMetadataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ExtractStridedMetadataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ExtractStridedMetadataOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() >= 2u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ExtractStridedMetadataOp ExtractStridedMetadataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtractStridedMetadataOp ExtractStridedMetadataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ExtractStridedMetadataOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() >= 2u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ExtractStridedMetadataOp ExtractStridedMetadataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtractStridedMetadataOp ExtractStridedMetadataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void ExtractStridedMetadataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ExtractStridedMetadataOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() >= 2u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } ExtractStridedMetadataOp ExtractStridedMetadataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtractStridedMetadataOp ExtractStridedMetadataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ExtractStridedMetadataOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps9(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps12(*this, v.getType(), "result", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSResults(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps11(*this, v.getType(), "result", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSResults(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSResults(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ExtractStridedMetadataOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ExtractStridedMetadataOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(&sourceRawOperand, 1); ::llvm::SMLoc sourceOperandsLoc; (void)sourceOperandsLoc; ::mlir::Type sourceRawType{}; ::llvm::ArrayRef<::mlir::Type> sourceTypes(&sourceRawType, 1); ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; sourceOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sourceRawOperand)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); sourceRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); if (parser.parseTypeList(allResultTypes)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } result.addTypes(allResultTypes); if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ExtractStridedMetadataOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSource(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSource().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; _odsPrinter << getOperation()->getResultTypes(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } void ExtractStridedMetadataOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } ::llvm::LogicalResult ExtractStridedMetadataOp::inferReturnTypes(::mlir::MLIRContext *context, std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { ExtractStridedMetadataOp::Adaptor adaptor(operands, attributes, properties, regions); return ExtractStridedMetadataOp::inferReturnTypes(context, location, adaptor, inferredReturnTypes); } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::ExtractStridedMetadataOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::GetGlobalOp definitions //===----------------------------------------------------------------------===// namespace detail { GetGlobalOpGenericAdaptorBase::GetGlobalOpGenericAdaptorBase(GetGlobalOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::llvm::StringRef GetGlobalOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr.getValue(); } } // namespace detail GetGlobalOpAdaptor::GetGlobalOpAdaptor(GetGlobalOp op) : GetGlobalOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GetGlobalOpAdaptor::verify(::mlir::Location loc) { auto tblgen_name = getProperties().name; (void)tblgen_name; if (!tblgen_name) return emitError(loc, "'memref.get_global' op requires attribute 'name'"); if (tblgen_name && !((::llvm::isa<::mlir::FlatSymbolRefAttr>(tblgen_name)))) return emitError(loc, "'memref.get_global' op attribute 'name' failed to satisfy constraint: flat symbol reference attribute"); return ::mlir::success(); } ::llvm::LogicalResult GetGlobalOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute GetGlobalOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code GetGlobalOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.name.getAsOpaquePointer())); } std::optional GetGlobalOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "name") return prop.name; return std::nullopt; } void GetGlobalOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } } void GetGlobalOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.name) attrs.append("name", prop.name); } ::llvm::LogicalResult GetGlobalOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps7(attr, "name", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult GetGlobalOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.name))) return ::mlir::failure(); return ::mlir::success(); } void GetGlobalOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.name); } ::llvm::StringRef GetGlobalOp::getName() { auto attr = getNameAttr(); return attr.getValue(); } void GetGlobalOp::setName(::llvm::StringRef attrValue) { getProperties().name = ::mlir::SymbolRefAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void GetGlobalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::FlatSymbolRefAttr name) { odsState.getOrAddProperties().name = name; odsState.addTypes(result); } GetGlobalOp GetGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::FlatSymbolRefAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetGlobalOp GetGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::FlatSymbolRefAttr name) { return create(builder, builder.getLoc(), std::forward(result), std::forward(name)); } void GetGlobalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::FlatSymbolRefAttr name) { odsState.getOrAddProperties().name = name; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } GetGlobalOp GetGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::FlatSymbolRefAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetGlobalOp GetGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::FlatSymbolRefAttr name) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(name)); } void GetGlobalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::llvm::StringRef name) { odsState.getOrAddProperties().name = ::mlir::SymbolRefAttr::get(odsBuilder.getContext(), name); odsState.addTypes(result); } GetGlobalOp GetGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::llvm::StringRef name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetGlobalOp GetGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::llvm::StringRef name) { return create(builder, builder.getLoc(), std::forward(result), std::forward(name)); } void GetGlobalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef name) { odsState.getOrAddProperties().name = ::mlir::SymbolRefAttr::get(odsBuilder.getContext(), name); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } GetGlobalOp GetGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetGlobalOp GetGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef name) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(name)); } void GetGlobalOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } GetGlobalOp GetGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetGlobalOp GetGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void GetGlobalOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } GetGlobalOp GetGlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetGlobalOp GetGlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult GetGlobalOp::verifyInvariantsImpl() { auto tblgen_name = getProperties().name; (void)tblgen_name; if (!tblgen_name) return emitOpError("requires attribute 'name'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps7(*this, tblgen_name, "name"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps13(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult GetGlobalOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult GetGlobalOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::FlatSymbolRefAttr nameAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); if (parser.parseCustomAttributeWithFallback(nameAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (nameAttr) result.getOrAddProperties().name = nameAttr; if (parser.parseColon()) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resultRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } result.addTypes(resultTypes); return ::mlir::success(); } void GetGlobalOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getNameAttr()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getResult().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("name"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } void GetGlobalOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::GetGlobalOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::detail::GetGlobalOpGenericAdaptorBase::Properties) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::GlobalOp definitions //===----------------------------------------------------------------------===// namespace detail { GlobalOpGenericAdaptorBase::GlobalOpGenericAdaptorBase(GlobalOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::llvm::StringRef GlobalOpGenericAdaptorBase::getSymName() { auto attr = getSymNameAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > GlobalOpGenericAdaptorBase::getSymVisibility() { auto attr = getSymVisibilityAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::mlir::MemRefType GlobalOpGenericAdaptorBase::getType() { auto attr = getTypeAttr(); return ::llvm::cast<::mlir::MemRefType>(attr.getValue()); } ::std::optional<::mlir::Attribute> GlobalOpGenericAdaptorBase::getInitialValue() { auto attr = getInitialValueAttr(); return attr ? ::std::optional<::mlir::Attribute>(attr) : (::std::nullopt); } ::mlir::UnitAttr GlobalOpGenericAdaptorBase::getConstantAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().constant); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool GlobalOpGenericAdaptorBase::getConstant() { auto attr = getConstantAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::std::optional GlobalOpGenericAdaptorBase::getAlignment() { auto attr = getAlignmentAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } } // namespace detail GlobalOpAdaptor::GlobalOpAdaptor(GlobalOp op) : GlobalOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GlobalOpAdaptor::verify(::mlir::Location loc) { auto tblgen_alignment = getProperties().alignment; (void)tblgen_alignment; auto tblgen_constant = getProperties().constant; (void)tblgen_constant; auto tblgen_initial_value = getProperties().initial_value; (void)tblgen_initial_value; auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; if (!tblgen_sym_name) return emitError(loc, "'memref.global' op requires attribute 'sym_name'"); auto tblgen_sym_visibility = getProperties().sym_visibility; (void)tblgen_sym_visibility; auto tblgen_type = getProperties().type; (void)tblgen_type; if (!tblgen_type) return emitError(loc, "'memref.global' op requires attribute 'type'"); if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name)))) return emitError(loc, "'memref.global' op attribute 'sym_name' failed to satisfy constraint: string attribute"); if (tblgen_sym_visibility && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_visibility)))) return emitError(loc, "'memref.global' op attribute 'sym_visibility' failed to satisfy constraint: string attribute"); if (tblgen_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_type))) && ((::llvm::isa<::mlir::MemRefType>(::llvm::cast<::mlir::TypeAttr>(tblgen_type).getValue()))) && ((true)))) return emitError(loc, "'memref.global' op attribute 'type' failed to satisfy constraint: memref type attribute"); if (tblgen_initial_value && !((true))) return emitError(loc, "'memref.global' op attribute 'initial_value' failed to satisfy constraint: any attribute"); if (tblgen_constant && !((::llvm::isa<::mlir::UnitAttr>(tblgen_constant)))) return emitError(loc, "'memref.global' op attribute 'constant' failed to satisfy constraint: unit attribute"); if (tblgen_alignment && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_alignment))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getType().isSignlessInteger(64)))) && (((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getValue().isStrictlyPositive())) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getValue().isPowerOf2()))))) return emitError(loc, "'memref.global' op attribute 'alignment' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive and whose value is a power of two > 0"); return ::mlir::success(); } ::llvm::LogicalResult GlobalOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.alignment; auto attr = dict.get("alignment"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `alignment` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.constant; auto attr = dict.get("constant"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `constant` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.initial_value; auto attr = dict.get("initial_value"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `initial_value` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sym_name; auto attr = dict.get("sym_name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sym_name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sym_visibility; auto attr = dict.get("sym_visibility"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sym_visibility` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.type; auto attr = dict.get("type"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `type` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute GlobalOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.alignment; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("alignment", propStorage)); } { const auto &propStorage = prop.constant; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("constant", propStorage)); } { const auto &propStorage = prop.initial_value; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("initial_value", propStorage)); } { const auto &propStorage = prop.sym_name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sym_name", propStorage)); } { const auto &propStorage = prop.sym_visibility; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sym_visibility", propStorage)); } { const auto &propStorage = prop.type; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("type", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code GlobalOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.alignment.getAsOpaquePointer()), llvm::hash_value(prop.constant.getAsOpaquePointer()), llvm::hash_value(prop.initial_value.getAsOpaquePointer()), llvm::hash_value(prop.sym_name.getAsOpaquePointer()), llvm::hash_value(prop.sym_visibility.getAsOpaquePointer()), llvm::hash_value(prop.type.getAsOpaquePointer())); } std::optional GlobalOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "alignment") return prop.alignment; if (name == "constant") return prop.constant; if (name == "initial_value") return prop.initial_value; if (name == "sym_name") return prop.sym_name; if (name == "sym_visibility") return prop.sym_visibility; if (name == "type") return prop.type; return std::nullopt; } void GlobalOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "alignment") { prop.alignment = ::llvm::dyn_cast_or_null>(value); return; } if (name == "constant") { prop.constant = ::llvm::dyn_cast_or_null>(value); return; } if (name == "initial_value") { prop.initial_value = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sym_name") { prop.sym_name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sym_visibility") { prop.sym_visibility = ::llvm::dyn_cast_or_null>(value); return; } if (name == "type") { prop.type = ::llvm::dyn_cast_or_null>(value); return; } } void GlobalOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.alignment) attrs.append("alignment", prop.alignment); if (prop.constant) attrs.append("constant", prop.constant); if (prop.initial_value) attrs.append("initial_value", prop.initial_value); if (prop.sym_name) attrs.append("sym_name", prop.sym_name); if (prop.sym_visibility) attrs.append("sym_visibility", prop.sym_visibility); if (prop.type) attrs.append("type", prop.type); } ::llvm::LogicalResult GlobalOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAlignmentAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps4(attr, "alignment", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getConstantAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps11(attr, "constant", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getInitialValueAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps10(attr, "initial_value", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps8(attr, "sym_name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSymVisibilityAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps8(attr, "sym_visibility", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps9(attr, "type", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult GlobalOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.alignment))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.constant))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.initial_value))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.sym_name))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.sym_visibility))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.type))) return ::mlir::failure(); return ::mlir::success(); } void GlobalOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.alignment); writer.writeOptionalAttribute(prop.constant); writer.writeOptionalAttribute(prop.initial_value); writer.writeAttribute(prop.sym_name); writer.writeOptionalAttribute(prop.sym_visibility); writer.writeAttribute(prop.type); } ::llvm::StringRef GlobalOp::getSymName() { auto attr = getSymNameAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > GlobalOp::getSymVisibility() { auto attr = getSymVisibilityAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::mlir::MemRefType GlobalOp::getType() { auto attr = getTypeAttr(); return ::llvm::cast<::mlir::MemRefType>(attr.getValue()); } ::std::optional<::mlir::Attribute> GlobalOp::getInitialValue() { auto attr = getInitialValueAttr(); return attr ? ::std::optional<::mlir::Attribute>(attr) : (::std::nullopt); } bool GlobalOp::getConstant() { auto attr = getConstantAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::std::optional GlobalOp::getAlignment() { auto attr = getAlignmentAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } void GlobalOp::setSymName(::llvm::StringRef attrValue) { getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue); } void GlobalOp::setSymVisibility(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().sym_visibility; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void GlobalOp::setType(::mlir::MemRefType attrValue) { getProperties().type = ::mlir::TypeAttr::get(attrValue); } void GlobalOp::setConstant(bool attrValue) { auto &odsProp = getProperties().constant; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void GlobalOp::setAlignment(::std::optional attrValue) { auto &odsProp = getProperties().alignment; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue); else odsProp = nullptr; } void GlobalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, /*optional*/::mlir::StringAttr sym_visibility, ::mlir::TypeAttr type, /*optional*/::mlir::Attribute initial_value, /*optional*/::mlir::UnitAttr constant, /*optional*/::mlir::IntegerAttr alignment) { odsState.getOrAddProperties().sym_name = sym_name; if (sym_visibility) { odsState.getOrAddProperties().sym_visibility = sym_visibility; } odsState.getOrAddProperties().type = type; if (initial_value) { odsState.getOrAddProperties().initial_value = initial_value; } if (constant) { odsState.getOrAddProperties().constant = constant; } if (alignment) { odsState.getOrAddProperties().alignment = alignment; } } GlobalOp GlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::StringAttr sym_name, /*optional*/::mlir::StringAttr sym_visibility, ::mlir::TypeAttr type, /*optional*/::mlir::Attribute initial_value, /*optional*/::mlir::UnitAttr constant, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sym_name), std::forward(sym_visibility), std::forward(type), std::forward(initial_value), std::forward(constant), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalOp GlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::StringAttr sym_name, /*optional*/::mlir::StringAttr sym_visibility, ::mlir::TypeAttr type, /*optional*/::mlir::Attribute initial_value, /*optional*/::mlir::UnitAttr constant, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(sym_name), std::forward(sym_visibility), std::forward(type), std::forward(initial_value), std::forward(constant), std::forward(alignment)); } void GlobalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, /*optional*/::mlir::StringAttr sym_visibility, ::mlir::TypeAttr type, /*optional*/::mlir::Attribute initial_value, /*optional*/::mlir::UnitAttr constant, /*optional*/::mlir::IntegerAttr alignment) { odsState.getOrAddProperties().sym_name = sym_name; if (sym_visibility) { odsState.getOrAddProperties().sym_visibility = sym_visibility; } odsState.getOrAddProperties().type = type; if (initial_value) { odsState.getOrAddProperties().initial_value = initial_value; } if (constant) { odsState.getOrAddProperties().constant = constant; } if (alignment) { odsState.getOrAddProperties().alignment = alignment; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } GlobalOp GlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, /*optional*/::mlir::StringAttr sym_visibility, ::mlir::TypeAttr type, /*optional*/::mlir::Attribute initial_value, /*optional*/::mlir::UnitAttr constant, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(sym_name), std::forward(sym_visibility), std::forward(type), std::forward(initial_value), std::forward(constant), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalOp GlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, /*optional*/::mlir::StringAttr sym_visibility, ::mlir::TypeAttr type, /*optional*/::mlir::Attribute initial_value, /*optional*/::mlir::UnitAttr constant, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(sym_name), std::forward(sym_visibility), std::forward(type), std::forward(initial_value), std::forward(constant), std::forward(alignment)); } void GlobalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, /*optional*/::mlir::StringAttr sym_visibility, ::mlir::MemRefType type, /*optional*/::mlir::Attribute initial_value, /*optional*/bool constant, /*optional*/::mlir::IntegerAttr alignment) { odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); if (sym_visibility) { odsState.getOrAddProperties().sym_visibility = sym_visibility; } odsState.getOrAddProperties().type = ::mlir::TypeAttr::get(type); if (initial_value) { odsState.getOrAddProperties().initial_value = initial_value; } if (constant) { odsState.getOrAddProperties().constant = ((constant) ? odsBuilder.getUnitAttr() : nullptr); } if (alignment) { odsState.getOrAddProperties().alignment = alignment; } } GlobalOp GlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef sym_name, /*optional*/::mlir::StringAttr sym_visibility, ::mlir::MemRefType type, /*optional*/::mlir::Attribute initial_value, /*optional*/bool constant, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sym_name), std::forward(sym_visibility), std::forward(type), std::forward(initial_value), std::forward(constant), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalOp GlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llvm::StringRef sym_name, /*optional*/::mlir::StringAttr sym_visibility, ::mlir::MemRefType type, /*optional*/::mlir::Attribute initial_value, /*optional*/bool constant, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(sym_name), std::forward(sym_visibility), std::forward(type), std::forward(initial_value), std::forward(constant), std::forward(alignment)); } void GlobalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, /*optional*/::mlir::StringAttr sym_visibility, ::mlir::MemRefType type, /*optional*/::mlir::Attribute initial_value, /*optional*/bool constant, /*optional*/::mlir::IntegerAttr alignment) { odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); if (sym_visibility) { odsState.getOrAddProperties().sym_visibility = sym_visibility; } odsState.getOrAddProperties().type = ::mlir::TypeAttr::get(type); if (initial_value) { odsState.getOrAddProperties().initial_value = initial_value; } if (constant) { odsState.getOrAddProperties().constant = ((constant) ? odsBuilder.getUnitAttr() : nullptr); } if (alignment) { odsState.getOrAddProperties().alignment = alignment; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } GlobalOp GlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, /*optional*/::mlir::StringAttr sym_visibility, ::mlir::MemRefType type, /*optional*/::mlir::Attribute initial_value, /*optional*/bool constant, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(sym_name), std::forward(sym_visibility), std::forward(type), std::forward(initial_value), std::forward(constant), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalOp GlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, /*optional*/::mlir::StringAttr sym_visibility, ::mlir::MemRefType type, /*optional*/::mlir::Attribute initial_value, /*optional*/bool constant, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(sym_name), std::forward(sym_visibility), std::forward(type), std::forward(initial_value), std::forward(constant), std::forward(alignment)); } void GlobalOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } GlobalOp GlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalOp GlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void GlobalOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } GlobalOp GlobalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalOp GlobalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult GlobalOp::verifyInvariantsImpl() { auto tblgen_alignment = getProperties().alignment; (void)tblgen_alignment; auto tblgen_constant = getProperties().constant; (void)tblgen_constant; auto tblgen_initial_value = getProperties().initial_value; (void)tblgen_initial_value; auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'"); auto tblgen_sym_visibility = getProperties().sym_visibility; (void)tblgen_sym_visibility; auto tblgen_type = getProperties().type; (void)tblgen_type; if (!tblgen_type) return emitOpError("requires attribute 'type'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps8(*this, tblgen_sym_name, "sym_name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps8(*this, tblgen_sym_visibility, "sym_visibility"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps9(*this, tblgen_type, "type"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps10(*this, tblgen_initial_value, "initial_value"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps11(*this, tblgen_constant, "constant"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps4(*this, tblgen_alignment, "alignment"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult GlobalOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult GlobalOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::StringAttr sym_visibilityAttr; ::mlir::StringAttr sym_nameAttr; ::mlir::TypeAttr typeAttr; ::mlir::Attribute initial_valueAttr; ::mlir::OptionalParseResult parseResultsym_visibilityAttr = parser.parseOptionalAttribute(sym_visibilityAttr, parser.getBuilder().getType<::mlir::NoneType>()); if (parseResultsym_visibilityAttr.has_value() && failed(*parseResultsym_visibilityAttr)) return ::mlir::failure(); if (parseResultsym_visibilityAttr.has_value() && succeeded(*parseResultsym_visibilityAttr)) if (sym_visibilityAttr) result.getOrAddProperties().sym_visibility = sym_visibilityAttr; if (sym_visibilityAttr) { } if (::mlir::succeeded(parser.parseOptionalKeyword("constant"))) { result.getOrAddProperties().constant = parser.getBuilder().getUnitAttr(); } if (parser.parseSymbolName(sym_nameAttr)) return ::mlir::failure(); if (sym_nameAttr) result.getOrAddProperties().sym_name = sym_nameAttr; if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseGlobalMemrefOpTypeAndInitialValue(parser, typeAttr, initial_valueAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().type = typeAttr; if (initial_valueAttr) result.getOrAddProperties().initial_value = initial_valueAttr; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } return ::mlir::success(); } void GlobalOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getSymVisibilityAttr()) { _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getSymVisibilityAttr()); } if ((getConstantAttr() && getConstantAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "constant"; } _odsPrinter << ' '; _odsPrinter.printSymbolName(getSymNameAttr().getValue()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printGlobalMemrefOpTypeAndInitialValue(_odsPrinter, *this, getTypeAttr(), getInitialValueAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("sym_visibility"); elidedAttrs.push_back("constant"); elidedAttrs.push_back("sym_name"); elidedAttrs.push_back("type"); elidedAttrs.push_back("initial_value"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getConstantAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("constant"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::GlobalOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::detail::GlobalOpGenericAdaptorBase::Properties) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::MemorySpaceCastOp definitions //===----------------------------------------------------------------------===// namespace detail { MemorySpaceCastOpGenericAdaptorBase::MemorySpaceCastOpGenericAdaptorBase(MemorySpaceCastOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail MemorySpaceCastOpAdaptor::MemorySpaceCastOpAdaptor(MemorySpaceCastOp op) : MemorySpaceCastOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MemorySpaceCastOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult MemorySpaceCastOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute MemorySpaceCastOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MemorySpaceCastOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional MemorySpaceCastOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void MemorySpaceCastOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void MemorySpaceCastOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult MemorySpaceCastOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void MemorySpaceCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::Value source) { odsState.addOperands(source); odsState.addTypes(dest); } MemorySpaceCastOp MemorySpaceCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type dest, ::mlir::Value source) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dest), std::forward(source)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MemorySpaceCastOp MemorySpaceCastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type dest, ::mlir::Value source) { return create(builder, builder.getLoc(), std::forward(dest), std::forward(source)); } void MemorySpaceCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source) { odsState.addOperands(source); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MemorySpaceCastOp MemorySpaceCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(source)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MemorySpaceCastOp MemorySpaceCastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(source)); } void MemorySpaceCastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MemorySpaceCastOp MemorySpaceCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MemorySpaceCastOp MemorySpaceCastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void MemorySpaceCastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MemorySpaceCastOp MemorySpaceCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MemorySpaceCastOp MemorySpaceCastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult MemorySpaceCastOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps6(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MemorySpaceCastOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult MemorySpaceCastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(&sourceRawOperand, 1); ::llvm::SMLoc sourceOperandsLoc; (void)sourceOperandsLoc; ::mlir::Type sourceRawType{}; ::llvm::ArrayRef<::mlir::Type> sourceTypes(&sourceRawType, 1); ::mlir::Type destRawType{}; ::llvm::ArrayRef<::mlir::Type> destTypes(&destRawType, 1); sourceOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sourceRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::BaseMemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); sourceRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::BaseMemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); destRawType = type; } result.addTypes(destTypes); if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MemorySpaceCastOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSource(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSource().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::BaseMemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getDest().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::BaseMemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void MemorySpaceCastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::MemorySpaceCastOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::PrefetchOp definitions //===----------------------------------------------------------------------===// namespace detail { PrefetchOpGenericAdaptorBase::PrefetchOpGenericAdaptorBase(PrefetchOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair PrefetchOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } bool PrefetchOpGenericAdaptorBase::getIsWrite() { auto attr = getIsWriteAttr(); return attr.getValue(); } uint32_t PrefetchOpGenericAdaptorBase::getLocalityHint() { auto attr = getLocalityHintAttr(); return attr.getValue().getZExtValue(); } bool PrefetchOpGenericAdaptorBase::getIsDataCache() { auto attr = getIsDataCacheAttr(); return attr.getValue(); } } // namespace detail PrefetchOpAdaptor::PrefetchOpAdaptor(PrefetchOp op) : PrefetchOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult PrefetchOpAdaptor::verify(::mlir::Location loc) { auto tblgen_isDataCache = getProperties().isDataCache; (void)tblgen_isDataCache; if (!tblgen_isDataCache) return emitError(loc, "'memref.prefetch' op requires attribute 'isDataCache'"); auto tblgen_isWrite = getProperties().isWrite; (void)tblgen_isWrite; if (!tblgen_isWrite) return emitError(loc, "'memref.prefetch' op requires attribute 'isWrite'"); auto tblgen_localityHint = getProperties().localityHint; (void)tblgen_localityHint; if (!tblgen_localityHint) return emitError(loc, "'memref.prefetch' op requires attribute 'localityHint'"); if (tblgen_isWrite && !((::llvm::isa<::mlir::BoolAttr>(tblgen_isWrite)))) return emitError(loc, "'memref.prefetch' op attribute 'isWrite' failed to satisfy constraint: bool attribute"); if (tblgen_localityHint && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_localityHint))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_localityHint).getType().isSignlessInteger(32)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_localityHint).getInt() >= 0)) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_localityHint).getInt() <= 3)))) return emitError(loc, "'memref.prefetch' op attribute 'localityHint' failed to satisfy constraint: 32-bit signless integer attribute whose minimum value is 0 whose maximum value is 3"); if (tblgen_isDataCache && !((::llvm::isa<::mlir::BoolAttr>(tblgen_isDataCache)))) return emitError(loc, "'memref.prefetch' op attribute 'isDataCache' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair PrefetchOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange PrefetchOp::getIndicesMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult PrefetchOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.isDataCache; auto attr = dict.get("isDataCache"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `isDataCache` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.isWrite; auto attr = dict.get("isWrite"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `isWrite` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.localityHint; auto attr = dict.get("localityHint"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `localityHint` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute PrefetchOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.isDataCache; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("isDataCache", propStorage)); } { const auto &propStorage = prop.isWrite; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("isWrite", propStorage)); } { const auto &propStorage = prop.localityHint; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("localityHint", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code PrefetchOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.isDataCache.getAsOpaquePointer()), llvm::hash_value(prop.isWrite.getAsOpaquePointer()), llvm::hash_value(prop.localityHint.getAsOpaquePointer())); } std::optional PrefetchOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "isDataCache") return prop.isDataCache; if (name == "isWrite") return prop.isWrite; if (name == "localityHint") return prop.localityHint; return std::nullopt; } void PrefetchOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "isDataCache") { prop.isDataCache = ::llvm::dyn_cast_or_null>(value); return; } if (name == "isWrite") { prop.isWrite = ::llvm::dyn_cast_or_null>(value); return; } if (name == "localityHint") { prop.localityHint = ::llvm::dyn_cast_or_null>(value); return; } } void PrefetchOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.isDataCache) attrs.append("isDataCache", prop.isDataCache); if (prop.isWrite) attrs.append("isWrite", prop.isWrite); if (prop.localityHint) attrs.append("localityHint", prop.localityHint); } ::llvm::LogicalResult PrefetchOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getIsDataCacheAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps3(attr, "isDataCache", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getIsWriteAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps3(attr, "isWrite", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getLocalityHintAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps12(attr, "localityHint", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult PrefetchOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.isDataCache))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.isWrite))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.localityHint))) return ::mlir::failure(); return ::mlir::success(); } void PrefetchOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.isDataCache); writer.writeAttribute(prop.isWrite); writer.writeAttribute(prop.localityHint); } bool PrefetchOp::getIsWrite() { auto attr = getIsWriteAttr(); return attr.getValue(); } uint32_t PrefetchOp::getLocalityHint() { auto attr = getLocalityHintAttr(); return attr.getValue().getZExtValue(); } bool PrefetchOp::getIsDataCache() { auto attr = getIsDataCacheAttr(); return attr.getValue(); } void PrefetchOp::setIsWrite(bool attrValue) { getProperties().isWrite = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void PrefetchOp::setLocalityHint(uint32_t attrValue) { getProperties().localityHint = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); } void PrefetchOp::setIsDataCache(bool attrValue) { getProperties().isDataCache = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void PrefetchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value memref, ::mlir::ValueRange indices, ::mlir::BoolAttr isWrite, ::mlir::IntegerAttr localityHint, ::mlir::BoolAttr isDataCache) { odsState.addOperands(memref); odsState.addOperands(indices); odsState.getOrAddProperties().isWrite = isWrite; odsState.getOrAddProperties().localityHint = localityHint; odsState.getOrAddProperties().isDataCache = isDataCache; } PrefetchOp PrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value memref, ::mlir::ValueRange indices, ::mlir::BoolAttr isWrite, ::mlir::IntegerAttr localityHint, ::mlir::BoolAttr isDataCache) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memref), std::forward(indices), std::forward(isWrite), std::forward(localityHint), std::forward(isDataCache)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrefetchOp PrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value memref, ::mlir::ValueRange indices, ::mlir::BoolAttr isWrite, ::mlir::IntegerAttr localityHint, ::mlir::BoolAttr isDataCache) { return create(builder, builder.getLoc(), std::forward(memref), std::forward(indices), std::forward(isWrite), std::forward(localityHint), std::forward(isDataCache)); } void PrefetchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value memref, ::mlir::ValueRange indices, ::mlir::BoolAttr isWrite, ::mlir::IntegerAttr localityHint, ::mlir::BoolAttr isDataCache) { odsState.addOperands(memref); odsState.addOperands(indices); odsState.getOrAddProperties().isWrite = isWrite; odsState.getOrAddProperties().localityHint = localityHint; odsState.getOrAddProperties().isDataCache = isDataCache; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } PrefetchOp PrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value memref, ::mlir::ValueRange indices, ::mlir::BoolAttr isWrite, ::mlir::IntegerAttr localityHint, ::mlir::BoolAttr isDataCache) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(memref), std::forward(indices), std::forward(isWrite), std::forward(localityHint), std::forward(isDataCache)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrefetchOp PrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value memref, ::mlir::ValueRange indices, ::mlir::BoolAttr isWrite, ::mlir::IntegerAttr localityHint, ::mlir::BoolAttr isDataCache) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(memref), std::forward(indices), std::forward(isWrite), std::forward(localityHint), std::forward(isDataCache)); } void PrefetchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value memref, ::mlir::ValueRange indices, bool isWrite, uint32_t localityHint, bool isDataCache) { odsState.addOperands(memref); odsState.addOperands(indices); odsState.getOrAddProperties().isWrite = odsBuilder.getBoolAttr(isWrite); odsState.getOrAddProperties().localityHint = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), localityHint); odsState.getOrAddProperties().isDataCache = odsBuilder.getBoolAttr(isDataCache); } PrefetchOp PrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value memref, ::mlir::ValueRange indices, bool isWrite, uint32_t localityHint, bool isDataCache) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memref), std::forward(indices), std::forward(isWrite), std::forward(localityHint), std::forward(isDataCache)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrefetchOp PrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value memref, ::mlir::ValueRange indices, bool isWrite, uint32_t localityHint, bool isDataCache) { return create(builder, builder.getLoc(), std::forward(memref), std::forward(indices), std::forward(isWrite), std::forward(localityHint), std::forward(isDataCache)); } void PrefetchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value memref, ::mlir::ValueRange indices, bool isWrite, uint32_t localityHint, bool isDataCache) { odsState.addOperands(memref); odsState.addOperands(indices); odsState.getOrAddProperties().isWrite = odsBuilder.getBoolAttr(isWrite); odsState.getOrAddProperties().localityHint = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), localityHint); odsState.getOrAddProperties().isDataCache = odsBuilder.getBoolAttr(isDataCache); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } PrefetchOp PrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value memref, ::mlir::ValueRange indices, bool isWrite, uint32_t localityHint, bool isDataCache) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(memref), std::forward(indices), std::forward(isWrite), std::forward(localityHint), std::forward(isDataCache)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrefetchOp PrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value memref, ::mlir::ValueRange indices, bool isWrite, uint32_t localityHint, bool isDataCache) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(memref), std::forward(indices), std::forward(isWrite), std::forward(localityHint), std::forward(isDataCache)); } void PrefetchOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } PrefetchOp PrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrefetchOp PrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void PrefetchOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } PrefetchOp PrefetchOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrefetchOp PrefetchOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult PrefetchOp::verifyInvariantsImpl() { auto tblgen_isDataCache = getProperties().isDataCache; (void)tblgen_isDataCache; if (!tblgen_isDataCache) return emitOpError("requires attribute 'isDataCache'"); auto tblgen_isWrite = getProperties().isWrite; (void)tblgen_isWrite; if (!tblgen_isWrite) return emitOpError("requires attribute 'isWrite'"); auto tblgen_localityHint = getProperties().localityHint; (void)tblgen_localityHint; if (!tblgen_localityHint) return emitOpError("requires attribute 'localityHint'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps3(*this, tblgen_isWrite, "isWrite"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps12(*this, tblgen_localityHint, "localityHint"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps3(*this, tblgen_isDataCache, "isDataCache"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult PrefetchOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult PrefetchOp::setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } // keep track of used keys in the input dictionary to be able to error out // if there are some unknown ones. ::mlir::DenseSet<::mlir::StringAttr> usedKeys; ::mlir::MLIRContext *ctx = dict.getContext(); (void)ctx; { auto &propStorage = prop.isWrite; auto isWriteAttrName = ::mlir::StringAttr::get(ctx, "isWrite"); auto attr = dict.get(isWriteAttrName); usedKeys.insert(isWriteAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for isWrite in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `isWrite` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.localityHint; auto localityHintAttrName = ::mlir::StringAttr::get(ctx, "localityHint"); auto attr = dict.get(localityHintAttrName); usedKeys.insert(localityHintAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for localityHint in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `localityHint` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.isDataCache; auto isDataCacheAttrName = ::mlir::StringAttr::get(ctx, "isDataCache"); auto attr = dict.get(isDataCacheAttrName); usedKeys.insert(isDataCacheAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for isDataCache in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `isDataCache` in property conversion: " << attr; return ::mlir::failure(); } } } for (::mlir::NamedAttribute attr : dict) { if (!usedKeys.contains(attr.getName())) return emitError() << "unknown key '" << attr.getName() << "' when parsing properties dictionary"; } return ::mlir::success(); } void PrefetchOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { { auto valueRange = getODSOperandIndexAndLength(0); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get()); } } } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::PrefetchOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::detail::PrefetchOpGenericAdaptorBase::Properties) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::RankOp definitions //===----------------------------------------------------------------------===// namespace detail { RankOpGenericAdaptorBase::RankOpGenericAdaptorBase(RankOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail RankOpAdaptor::RankOpAdaptor(RankOp op) : RankOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult RankOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult RankOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute RankOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code RankOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional RankOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void RankOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void RankOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult RankOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void RankOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value memref) { odsState.addOperands(memref); odsState.addTypes(resultType0); } RankOp RankOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type resultType0, ::mlir::Value memref) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType0), std::forward(memref)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RankOp RankOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type resultType0, ::mlir::Value memref) { return create(builder, builder.getLoc(), std::forward(resultType0), std::forward(memref)); } void RankOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value memref) { odsState.addOperands(memref); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(RankOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, odsState.operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) odsState.addTypes(inferredReturnTypes); else ::mlir::detail::reportFatalInferReturnTypesError(odsState); } RankOp RankOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value memref) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(memref)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RankOp RankOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value memref) { return create(builder, builder.getLoc(), std::forward(memref)); } void RankOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value memref) { odsState.addOperands(memref); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } RankOp RankOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value memref) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(memref)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RankOp RankOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value memref) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(memref)); } void RankOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } RankOp RankOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RankOp RankOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void RankOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(RankOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } RankOp RankOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RankOp RankOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void RankOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } RankOp RankOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RankOp RankOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } void RankOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(RankOp::inferReturnTypes(odsBuilder.getContext(), odsState.location, operands, odsState.attributes.getDictionary(odsState.getContext()), odsState.getRawProperties(), odsState.regions, inferredReturnTypes))) { assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(inferredReturnTypes); } else { ::llvm::report_fatal_error("Failed to infer result type(s)."); } } RankOp RankOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RankOp RankOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult RankOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps11(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult RankOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult RankOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult RankOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand memrefRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> memrefOperands(&memrefRawOperand, 1); ::llvm::SMLoc memrefOperandsLoc; (void)memrefOperandsLoc; ::mlir::Type memrefRawType{}; ::llvm::ArrayRef<::mlir::Type> memrefTypes(&memrefRawType, 1); memrefOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(memrefRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::BaseMemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); memrefRawType = type; } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); result.addTypes(odsBuildableType0); if (parser.resolveOperands(memrefOperands, memrefTypes, memrefOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void RankOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getMemref(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getMemref().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::BaseMemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void RankOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::RankOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::ReallocOp definitions //===----------------------------------------------------------------------===// namespace detail { ReallocOpGenericAdaptorBase::ReallocOpGenericAdaptorBase(ReallocOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ReallocOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::std::optional ReallocOpGenericAdaptorBase::getAlignment() { auto attr = getAlignmentAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } } // namespace detail ReallocOpAdaptor::ReallocOpAdaptor(ReallocOp op) : ReallocOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ReallocOpAdaptor::verify(::mlir::Location loc) { auto tblgen_alignment = getProperties().alignment; (void)tblgen_alignment; if (tblgen_alignment && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_alignment))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getType().isSignlessInteger(64)))) && (((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getValue().isStrictlyPositive())) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getValue().isPowerOf2()))))) return emitError(loc, "'memref.realloc' op attribute 'alignment' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive and whose value is a power of two > 0"); return ::mlir::success(); } std::pair ReallocOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange ReallocOp::getDynamicResultSizeMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult ReallocOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.alignment; auto attr = dict.get("alignment"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `alignment` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ReallocOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.alignment; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("alignment", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ReallocOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.alignment.getAsOpaquePointer())); } std::optional ReallocOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "alignment") return prop.alignment; return std::nullopt; } void ReallocOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "alignment") { prop.alignment = ::llvm::dyn_cast_or_null>(value); return; } } void ReallocOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.alignment) attrs.append("alignment", prop.alignment); } ::llvm::LogicalResult ReallocOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAlignmentAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps4(attr, "alignment", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ReallocOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.alignment))) return ::mlir::failure(); return ::mlir::success(); } void ReallocOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.alignment); } ::std::optional ReallocOp::getAlignment() { auto attr = getAlignmentAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } void ReallocOp::setAlignment(::std::optional attrValue) { auto &odsProp = getProperties().alignment; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue); else odsProp = nullptr; } void ReallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, MemRefType resultType, Value source, Value dynamicResultSize) { return build(odsBuilder, odsState, resultType, source, dynamicResultSize, IntegerAttr()); } ReallocOp ReallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, MemRefType resultType, Value source, Value dynamicResultSize) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(source), std::forward(dynamicResultSize)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReallocOp ReallocOp::create(::mlir::ImplicitLocOpBuilder &builder, MemRefType resultType, Value source, Value dynamicResultSize) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(source), std::forward(dynamicResultSize)); } void ReallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value source, /*optional*/::mlir::Value dynamicResultSize, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(source); if (dynamicResultSize) odsState.addOperands(dynamicResultSize); if (alignment) { odsState.getOrAddProperties().alignment = alignment; } odsState.addTypes(resultType0); } ReallocOp ReallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type resultType0, ::mlir::Value source, /*optional*/::mlir::Value dynamicResultSize, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType0), std::forward(source), std::forward(dynamicResultSize), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReallocOp ReallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type resultType0, ::mlir::Value source, /*optional*/::mlir::Value dynamicResultSize, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(resultType0), std::forward(source), std::forward(dynamicResultSize), std::forward(alignment)); } void ReallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, /*optional*/::mlir::Value dynamicResultSize, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(source); if (dynamicResultSize) odsState.addOperands(dynamicResultSize); if (alignment) { odsState.getOrAddProperties().alignment = alignment; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReallocOp ReallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source, /*optional*/::mlir::Value dynamicResultSize, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(source), std::forward(dynamicResultSize), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReallocOp ReallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source, /*optional*/::mlir::Value dynamicResultSize, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(source), std::forward(dynamicResultSize), std::forward(alignment)); } void ReallocOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ReallocOp ReallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReallocOp ReallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ReallocOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ReallocOp ReallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReallocOp ReallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ReallocOp::verifyInvariantsImpl() { auto tblgen_alignment = getProperties().alignment; (void)tblgen_alignment; if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps4(*this, tblgen_alignment, "alignment"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps14(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps14(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ReallocOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ReallocOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(&sourceRawOperand, 1); ::llvm::SMLoc sourceOperandsLoc; (void)sourceOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dynamicResultSizeOperands; ::llvm::SMLoc dynamicResultSizeOperandsLoc; (void)dynamicResultSizeOperandsLoc; ::mlir::Type sourceRawType{}; ::llvm::ArrayRef<::mlir::Type> sourceTypes(&sourceRawType, 1); ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; sourceOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sourceRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalLParen())) { { dynamicResultSizeOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); dynamicResultSizeOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); sourceRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); if (parser.parseTypeList(allResultTypes)) return ::mlir::failure(); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); result.addTypes(allResultTypes); if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) return ::mlir::failure(); if (!dynamicResultSizeOperands.empty()) { if (parser.resolveOperands(dynamicResultSizeOperands, odsBuildableType0, dynamicResultSizeOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void ReallocOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSource(); if (getDynamicResultSize()) { _odsPrinter << "("; if (::mlir::Value value = getDynamicResultSize()) _odsPrinter << value; _odsPrinter << ")"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSource().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; _odsPrinter << getOperation()->getResultTypes(); } void ReallocOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { { auto valueRange = getODSOperandIndexAndLength(0); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Free::get(), &getOperation()->getOpOperand(idx), 0, true, ::mlir::SideEffects::DefaultResource::get()); } } { auto valueRange = getODSResultIndexAndLength(0); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Allocate::get(), getOperation()->getOpResult(idx), 1, true, ::mlir::SideEffects::DefaultResource::get()); } } } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::ReallocOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::detail::ReallocOpGenericAdaptorBase::Properties) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::ReinterpretCastOp definitions //===----------------------------------------------------------------------===// namespace detail { ReinterpretCastOpGenericAdaptorBase::ReinterpretCastOpGenericAdaptorBase(ReinterpretCastOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ReinterpretCastOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::llvm::ArrayRef ReinterpretCastOpGenericAdaptorBase::getStaticOffsets() { auto attr = getStaticOffsetsAttr(); return attr; } ::llvm::ArrayRef ReinterpretCastOpGenericAdaptorBase::getStaticSizes() { auto attr = getStaticSizesAttr(); return attr; } ::llvm::ArrayRef ReinterpretCastOpGenericAdaptorBase::getStaticStrides() { auto attr = getStaticStridesAttr(); return attr; } } // namespace detail ReinterpretCastOpAdaptor::ReinterpretCastOpAdaptor(ReinterpretCastOp op) : ReinterpretCastOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ReinterpretCastOpAdaptor::verify(::mlir::Location loc) { auto tblgen_static_offsets = getProperties().static_offsets; (void)tblgen_static_offsets; if (!tblgen_static_offsets) return emitError(loc, "'memref.reinterpret_cast' op requires attribute 'static_offsets'"); auto tblgen_static_sizes = getProperties().static_sizes; (void)tblgen_static_sizes; if (!tblgen_static_sizes) return emitError(loc, "'memref.reinterpret_cast' op requires attribute 'static_sizes'"); auto tblgen_static_strides = getProperties().static_strides; (void)tblgen_static_strides; if (!tblgen_static_strides) return emitError(loc, "'memref.reinterpret_cast' op requires attribute 'static_strides'"); if (tblgen_static_offsets && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_offsets)))) return emitError(loc, "'memref.reinterpret_cast' op attribute 'static_offsets' failed to satisfy constraint: i64 dense array attribute"); if (tblgen_static_sizes && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_sizes)))) return emitError(loc, "'memref.reinterpret_cast' op attribute 'static_sizes' failed to satisfy constraint: i64 dense array attribute"); if (tblgen_static_strides && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_strides)))) return emitError(loc, "'memref.reinterpret_cast' op attribute 'static_strides' failed to satisfy constraint: i64 dense array attribute"); return ::mlir::success(); } std::pair ReinterpretCastOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange ReinterpretCastOp::getOffsetsMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ReinterpretCastOp::getSizesMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ReinterpretCastOp::getStridesMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult ReinterpretCastOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.static_offsets; auto attr = dict.get("static_offsets"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `static_offsets` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.static_sizes; auto attr = dict.get("static_sizes"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `static_sizes` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.static_strides; auto attr = dict.get("static_strides"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `static_strides` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute ReinterpretCastOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.static_offsets; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("static_offsets", propStorage)); } { const auto &propStorage = prop.static_sizes; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("static_sizes", propStorage)); } { const auto &propStorage = prop.static_strides; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("static_strides", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ReinterpretCastOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.static_offsets.getAsOpaquePointer()), llvm::hash_value(prop.static_sizes.getAsOpaquePointer()), llvm::hash_value(prop.static_strides.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional ReinterpretCastOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "static_offsets") return prop.static_offsets; if (name == "static_sizes") return prop.static_sizes; if (name == "static_strides") return prop.static_strides; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void ReinterpretCastOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "static_offsets") { prop.static_offsets = ::llvm::dyn_cast_or_null>(value); return; } if (name == "static_sizes") { prop.static_sizes = ::llvm::dyn_cast_or_null>(value); return; } if (name == "static_strides") { prop.static_strides = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void ReinterpretCastOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.static_offsets) attrs.append("static_offsets", prop.static_offsets); if (prop.static_sizes) attrs.append("static_sizes", prop.static_sizes); if (prop.static_strides) attrs.append("static_strides", prop.static_strides); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult ReinterpretCastOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getStaticOffsetsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps6(attr, "static_offsets", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStaticSizesAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps6(attr, "static_sizes", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStaticStridesAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps6(attr, "static_strides", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ReinterpretCastOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readAttribute(prop.static_offsets))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.static_sizes))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.static_strides))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void ReinterpretCastOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeAttribute(prop.static_offsets); writer.writeAttribute(prop.static_sizes); writer.writeAttribute(prop.static_strides); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::llvm::ArrayRef ReinterpretCastOp::getStaticOffsets() { auto attr = getStaticOffsetsAttr(); return attr; } ::llvm::ArrayRef ReinterpretCastOp::getStaticSizes() { auto attr = getStaticSizesAttr(); return attr; } ::llvm::ArrayRef ReinterpretCastOp::getStaticStrides() { auto attr = getStaticStridesAttr(); return attr; } void ReinterpretCastOp::setStaticOffsets(::llvm::ArrayRef attrValue) { getProperties().static_offsets = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); } void ReinterpretCastOp::setStaticSizes(::llvm::ArrayRef attrValue) { getProperties().static_sizes = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); } void ReinterpretCastOp::setStaticStrides(::llvm::ArrayRef attrValue) { getProperties().static_strides = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); } ReinterpretCastOp ReinterpretCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, MemRefType resultType, Value source, OpFoldResult offset, ArrayRef sizes, ArrayRef strides, ArrayRef attrs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(source), std::forward(offset), std::forward(sizes), std::forward(strides), std::forward(attrs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReinterpretCastOp ReinterpretCastOp::create(::mlir::ImplicitLocOpBuilder &builder, MemRefType resultType, Value source, OpFoldResult offset, ArrayRef sizes, ArrayRef strides, ArrayRef attrs) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(source), std::forward(offset), std::forward(sizes), std::forward(strides), std::forward(attrs)); } ReinterpretCastOp ReinterpretCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value source, OpFoldResult offset, ArrayRef sizes, ArrayRef strides, ArrayRef attrs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(source), std::forward(offset), std::forward(sizes), std::forward(strides), std::forward(attrs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReinterpretCastOp ReinterpretCastOp::create(::mlir::ImplicitLocOpBuilder &builder, Value source, OpFoldResult offset, ArrayRef sizes, ArrayRef strides, ArrayRef attrs) { return create(builder, builder.getLoc(), std::forward(source), std::forward(offset), std::forward(sizes), std::forward(strides), std::forward(attrs)); } ReinterpretCastOp ReinterpretCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, MemRefType resultType, Value source, int64_t offset, ArrayRef sizes, ArrayRef strides, ArrayRef attrs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(source), std::forward(offset), std::forward(sizes), std::forward(strides), std::forward(attrs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReinterpretCastOp ReinterpretCastOp::create(::mlir::ImplicitLocOpBuilder &builder, MemRefType resultType, Value source, int64_t offset, ArrayRef sizes, ArrayRef strides, ArrayRef attrs) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(source), std::forward(offset), std::forward(sizes), std::forward(strides), std::forward(attrs)); } ReinterpretCastOp ReinterpretCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, MemRefType resultType, Value source, Value offset, ValueRange sizes, ValueRange strides, ArrayRef attrs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(source), std::forward(offset), std::forward(sizes), std::forward(strides), std::forward(attrs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReinterpretCastOp ReinterpretCastOp::create(::mlir::ImplicitLocOpBuilder &builder, MemRefType resultType, Value source, Value offset, ValueRange sizes, ValueRange strides, ArrayRef attrs) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(source), std::forward(offset), std::forward(sizes), std::forward(strides), std::forward(attrs)); } void ReinterpretCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { odsState.addOperands(source); odsState.addOperands(offsets); odsState.addOperands(sizes); odsState.addOperands(strides); ::llvm::copy(::llvm::ArrayRef({1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().static_offsets = static_offsets; odsState.getOrAddProperties().static_sizes = static_sizes; odsState.getOrAddProperties().static_strides = static_strides; odsState.addTypes(result); } ReinterpretCastOp ReinterpretCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReinterpretCastOp ReinterpretCastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { return create(builder, builder.getLoc(), std::forward(result), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); } void ReinterpretCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { odsState.addOperands(source); odsState.addOperands(offsets); odsState.addOperands(sizes); odsState.addOperands(strides); ::llvm::copy(::llvm::ArrayRef({1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().static_offsets = static_offsets; odsState.getOrAddProperties().static_sizes = static_sizes; odsState.getOrAddProperties().static_strides = static_strides; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReinterpretCastOp ReinterpretCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReinterpretCastOp ReinterpretCastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); } void ReinterpretCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { odsState.addOperands(source); odsState.addOperands(offsets); odsState.addOperands(sizes); odsState.addOperands(strides); ::llvm::copy(::llvm::ArrayRef({1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().static_offsets = odsBuilder.getDenseI64ArrayAttr(static_offsets); odsState.getOrAddProperties().static_sizes = odsBuilder.getDenseI64ArrayAttr(static_sizes); odsState.getOrAddProperties().static_strides = odsBuilder.getDenseI64ArrayAttr(static_strides); odsState.addTypes(result); } ReinterpretCastOp ReinterpretCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReinterpretCastOp ReinterpretCastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { return create(builder, builder.getLoc(), std::forward(result), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); } void ReinterpretCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { odsState.addOperands(source); odsState.addOperands(offsets); odsState.addOperands(sizes); odsState.addOperands(strides); ::llvm::copy(::llvm::ArrayRef({1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().static_offsets = odsBuilder.getDenseI64ArrayAttr(static_offsets); odsState.getOrAddProperties().static_sizes = odsBuilder.getDenseI64ArrayAttr(static_sizes); odsState.getOrAddProperties().static_strides = odsBuilder.getDenseI64ArrayAttr(static_strides); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReinterpretCastOp ReinterpretCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReinterpretCastOp ReinterpretCastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); } void ReinterpretCastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ReinterpretCastOp ReinterpretCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReinterpretCastOp ReinterpretCastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ReinterpretCastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ReinterpretCastOp ReinterpretCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReinterpretCastOp ReinterpretCastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ReinterpretCastOp::verifyInvariantsImpl() { auto tblgen_static_offsets = getProperties().static_offsets; (void)tblgen_static_offsets; if (!tblgen_static_offsets) return emitOpError("requires attribute 'static_offsets'"); auto tblgen_static_sizes = getProperties().static_sizes; (void)tblgen_static_sizes; if (!tblgen_static_sizes) return emitOpError("requires attribute 'static_sizes'"); auto tblgen_static_strides = getProperties().static_strides; (void)tblgen_static_strides; if (!tblgen_static_strides) return emitOpError("requires attribute 'static_strides'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps6(*this, tblgen_static_offsets, "static_offsets"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps6(*this, tblgen_static_sizes, "static_sizes"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps6(*this, tblgen_static_strides, "static_strides"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps9(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ReinterpretCastOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ReinterpretCastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(&sourceRawOperand, 1); ::llvm::SMLoc sourceOperandsLoc; (void)sourceOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> offsetsOperands; ::llvm::SMLoc offsetsOperandsLoc; (void)offsetsOperandsLoc; ::mlir::DenseI64ArrayAttr static_offsetsAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> sizesOperands; ::llvm::SMLoc sizesOperandsLoc; (void)sizesOperandsLoc; ::mlir::DenseI64ArrayAttr static_sizesAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> stridesOperands; ::llvm::SMLoc stridesOperandsLoc; (void)stridesOperandsLoc; ::mlir::DenseI64ArrayAttr static_stridesAttr; ::mlir::Type sourceRawType{}; ::llvm::ArrayRef<::mlir::Type> sourceTypes(&sourceRawType, 1); ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); sourceOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sourceRawOperand)) return ::mlir::failure(); if (parser.parseKeyword("to")) return ::mlir::failure(); if (parser.parseKeyword("offset")) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); { offsetsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDynamicIndexList(parser, offsetsOperands, static_offsetsAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().static_offsets = static_offsetsAttr; } if (parser.parseComma()) return ::mlir::failure(); if (parser.parseKeyword("sizes")) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); { sizesOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDynamicIndexList(parser, sizesOperands, static_sizesAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().static_sizes = static_sizesAttr; } if (parser.parseComma()) return ::mlir::failure(); if (parser.parseKeyword("strides")) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); { stridesOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDynamicIndexList(parser, stridesOperands, static_stridesAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().static_strides = static_stridesAttr; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::BaseMemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); sourceRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resultRawType = type; } ::llvm::copy(::llvm::ArrayRef({1, static_cast(offsetsOperands.size()), static_cast(sizesOperands.size()), static_cast(stridesOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); result.addTypes(resultTypes); if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(offsetsOperands, odsBuildableType0, offsetsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(sizesOperands, odsBuildableType0, sizesOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(stridesOperands, odsBuildableType0, stridesOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ReinterpretCastOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSource(); _odsPrinter << ' ' << "to"; _odsPrinter << ' ' << "offset"; _odsPrinter << ":"; _odsPrinter << ' '; printDynamicIndexList(_odsPrinter, *this, getOffsets(), getStaticOffsetsAttr()); _odsPrinter << ","; _odsPrinter << ' ' << "sizes"; _odsPrinter << ":"; _odsPrinter << ' '; printDynamicIndexList(_odsPrinter, *this, getSizes(), getStaticSizesAttr()); _odsPrinter << ","; _odsPrinter << ' ' << "strides"; _odsPrinter << ":"; _odsPrinter << ' '; printDynamicIndexList(_odsPrinter, *this, getStrides(), getStaticStridesAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("static_offsets"); elidedAttrs.push_back("static_sizes"); elidedAttrs.push_back("static_strides"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSource().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::BaseMemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getResult().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ReinterpretCastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::ReinterpretCastOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::detail::ReinterpretCastOpGenericAdaptorBase::Properties) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::ReshapeOp definitions //===----------------------------------------------------------------------===// namespace detail { ReshapeOpGenericAdaptorBase::ReshapeOpGenericAdaptorBase(ReshapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail ReshapeOpAdaptor::ReshapeOpAdaptor(ReshapeOp op) : ReshapeOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ReshapeOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult ReshapeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute ReshapeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ReshapeOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional ReshapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void ReshapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void ReshapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult ReshapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void ReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, MemRefType resultType, Value operand, Value shape) { odsState.addOperands(operand); odsState.addOperands(shape); odsState.addTypes(resultType); } ReshapeOp ReshapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, MemRefType resultType, Value operand, Value shape) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(operand), std::forward(shape)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReshapeOp ReshapeOp::create(::mlir::ImplicitLocOpBuilder &builder, MemRefType resultType, Value operand, Value shape) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(operand), std::forward(shape)); } void ReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value shape) { odsState.addOperands(source); odsState.addOperands(shape); odsState.addTypes(result); } ReshapeOp ReshapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value source, ::mlir::Value shape) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(source), std::forward(shape)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReshapeOp ReshapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value source, ::mlir::Value shape) { return create(builder, builder.getLoc(), std::forward(result), std::forward(source), std::forward(shape)); } void ReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value shape) { odsState.addOperands(source); odsState.addOperands(shape); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReshapeOp ReshapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value shape) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(source), std::forward(shape)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReshapeOp ReshapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value shape) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(source), std::forward(shape)); } void ReshapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ReshapeOp ReshapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReshapeOp ReshapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ReshapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ReshapeOp ReshapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReshapeOp ReshapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ReshapeOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps15(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps6(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ReshapeOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ReshapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(&sourceRawOperand, 1); ::llvm::SMLoc sourceOperandsLoc; (void)sourceOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand shapeRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> shapeOperands(&shapeRawOperand, 1); ::llvm::SMLoc shapeOperandsLoc; (void)shapeOperandsLoc; ::llvm::ArrayRef<::mlir::Type> allOperandTypes; ::llvm::ArrayRef<::mlir::Type> allResultTypes; sourceOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sourceRawOperand)) return ::mlir::failure(); if (parser.parseLParen()) return ::mlir::failure(); shapeOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(shapeRawOperand)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); ::mlir::FunctionType allOperand__allResult_functionType; if (parser.parseType(allOperand__allResult_functionType)) return ::mlir::failure(); allOperandTypes = allOperand__allResult_functionType.getInputs(); allResultTypes = allOperand__allResult_functionType.getResults(); result.addTypes(allResultTypes); if (parser.resolveOperands(::llvm::concat(sourceOperands, shapeOperands), allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ReshapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSource(); _odsPrinter << "("; _odsPrinter << getShape(); _odsPrinter << ")"; ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); } void ReshapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { { auto valueRange = getODSOperandIndexAndLength(1); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Read::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get()); } } } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::ReshapeOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::StoreOp definitions //===----------------------------------------------------------------------===// namespace detail { StoreOpGenericAdaptorBase::StoreOpGenericAdaptorBase(StoreOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair StoreOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::BoolAttr StoreOpGenericAdaptorBase::getNontemporalAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().nontemporal); if (!attr) attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false); return attr; } bool StoreOpGenericAdaptorBase::getNontemporal() { auto attr = getNontemporalAttr(); if (!attr) return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue(); return attr.getValue(); } ::std::optional StoreOpGenericAdaptorBase::getAlignment() { auto attr = getAlignmentAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } } // namespace detail StoreOpAdaptor::StoreOpAdaptor(StoreOp op) : StoreOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult StoreOpAdaptor::verify(::mlir::Location loc) { auto tblgen_alignment = getProperties().alignment; (void)tblgen_alignment; auto tblgen_nontemporal = getProperties().nontemporal; (void)tblgen_nontemporal; if (tblgen_nontemporal && !((::llvm::isa<::mlir::BoolAttr>(tblgen_nontemporal)))) return emitError(loc, "'memref.store' op attribute 'nontemporal' failed to satisfy constraint: bool attribute"); if (tblgen_alignment && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_alignment))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getType().isSignlessInteger(64)))) && (((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getValue().isStrictlyPositive())) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_alignment).getValue().isPowerOf2()))))) return emitError(loc, "'memref.store' op attribute 'alignment' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive and whose value is a power of two > 0"); return ::mlir::success(); } std::pair StoreOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange StoreOp::getIndicesMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult StoreOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.alignment; auto attr = dict.get("alignment"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `alignment` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.nontemporal; auto attr = dict.get("nontemporal"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `nontemporal` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute StoreOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.alignment; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("alignment", propStorage)); } { const auto &propStorage = prop.nontemporal; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("nontemporal", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code StoreOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.alignment.getAsOpaquePointer()), llvm::hash_value(prop.nontemporal.getAsOpaquePointer())); } std::optional StoreOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "alignment") return prop.alignment; if (name == "nontemporal") return prop.nontemporal; return std::nullopt; } void StoreOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "alignment") { prop.alignment = ::llvm::dyn_cast_or_null>(value); return; } if (name == "nontemporal") { prop.nontemporal = ::llvm::dyn_cast_or_null>(value); return; } } void StoreOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.alignment) attrs.append("alignment", prop.alignment); if (prop.nontemporal) attrs.append("nontemporal", prop.nontemporal); } ::llvm::LogicalResult StoreOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAlignmentAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps4(attr, "alignment", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNontemporalAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps3(attr, "nontemporal", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult StoreOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.alignment))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.nontemporal))) return ::mlir::failure(); return ::mlir::success(); } void StoreOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.alignment); writer.writeOptionalAttribute(prop.nontemporal); } bool StoreOp::getNontemporal() { auto attr = getNontemporalAttr(); if (!attr) return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue(); return attr.getValue(); } ::std::optional StoreOp::getAlignment() { auto attr = getAlignmentAttr(); return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); } void StoreOp::setNontemporal(::std::optional attrValue) { auto &odsProp = getProperties().nontemporal; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue); else odsProp = nullptr; } void StoreOp::setAlignment(::std::optional attrValue) { auto &odsProp = getProperties().alignment; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue); else odsProp = nullptr; } void StoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value valueToStore, Value memref, ValueRange indices, bool nontemporal, llvm::MaybeAlign alignment) { return build(odsBuilder, odsState, valueToStore, memref, indices, nontemporal, alignment ? odsBuilder.getI64IntegerAttr(alignment->value()) : nullptr); } StoreOp StoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value valueToStore, Value memref, ValueRange indices, bool nontemporal, llvm::MaybeAlign alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(valueToStore), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } StoreOp StoreOp::create(::mlir::ImplicitLocOpBuilder &builder, Value valueToStore, Value memref, ValueRange indices, bool nontemporal, llvm::MaybeAlign alignment) { return create(builder, builder.getLoc(), std::forward(valueToStore), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); } void StoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value valueToStore, Value memref) { odsState.addOperands(valueToStore); odsState.addOperands(memref); } StoreOp StoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value valueToStore, Value memref) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(valueToStore), std::forward(memref)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } StoreOp StoreOp::create(::mlir::ImplicitLocOpBuilder &builder, Value valueToStore, Value memref) { return create(builder, builder.getLoc(), std::forward(valueToStore), std::forward(memref)); } void StoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/::mlir::BoolAttr nontemporal, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(value); odsState.addOperands(memref); odsState.addOperands(indices); if (nontemporal) { odsState.getOrAddProperties().nontemporal = nontemporal; } if (alignment) { odsState.getOrAddProperties().alignment = alignment; } } StoreOp StoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/::mlir::BoolAttr nontemporal, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(value), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } StoreOp StoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/::mlir::BoolAttr nontemporal, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(value), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); } void StoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/::mlir::BoolAttr nontemporal, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(value); odsState.addOperands(memref); odsState.addOperands(indices); if (nontemporal) { odsState.getOrAddProperties().nontemporal = nontemporal; } if (alignment) { odsState.getOrAddProperties().alignment = alignment; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } StoreOp StoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/::mlir::BoolAttr nontemporal, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(value), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } StoreOp StoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/::mlir::BoolAttr nontemporal, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(value), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); } void StoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/bool nontemporal, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(value); odsState.addOperands(memref); odsState.addOperands(indices); odsState.getOrAddProperties().nontemporal = odsBuilder.getBoolAttr(nontemporal); if (alignment) { odsState.getOrAddProperties().alignment = alignment; } } StoreOp StoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/bool nontemporal, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(value), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } StoreOp StoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/bool nontemporal, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(value), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); } void StoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/bool nontemporal, /*optional*/::mlir::IntegerAttr alignment) { odsState.addOperands(value); odsState.addOperands(memref); odsState.addOperands(indices); odsState.getOrAddProperties().nontemporal = odsBuilder.getBoolAttr(nontemporal); if (alignment) { odsState.getOrAddProperties().alignment = alignment; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } StoreOp StoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/bool nontemporal, /*optional*/::mlir::IntegerAttr alignment) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(value), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } StoreOp StoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value memref, ::mlir::ValueRange indices, /*optional*/bool nontemporal, /*optional*/::mlir::IntegerAttr alignment) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(value), std::forward(memref), std::forward(indices), std::forward(nontemporal), std::forward(alignment)); } void StoreOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } StoreOp StoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } StoreOp StoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void StoreOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } StoreOp StoreOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } StoreOp StoreOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult StoreOp::verifyInvariantsImpl() { auto tblgen_alignment = getProperties().alignment; (void)tblgen_alignment; auto tblgen_nontemporal = getProperties().nontemporal; (void)tblgen_nontemporal; if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps3(*this, tblgen_nontemporal, "nontemporal"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps4(*this, tblgen_alignment, "alignment"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } if (!((std::equal_to<>()(::llvm::cast((*this->getODSOperands(1).begin()).getType()).getElementType(), (*this->getODSOperands(0).begin()).getType())))) return emitOpError("failed to verify that type of 'value' matches element type of 'memref'"); return ::mlir::success(); } ::llvm::LogicalResult StoreOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult StoreOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand valueRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueOperands(&valueRawOperand, 1); ::llvm::SMLoc valueOperandsLoc; (void)valueOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand memrefRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> memrefOperands(&memrefRawOperand, 1); ::llvm::SMLoc memrefOperandsLoc; (void)memrefOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands; ::llvm::SMLoc indicesOperandsLoc; (void)indicesOperandsLoc; ::mlir::Type memrefRawType{}; ::llvm::ArrayRef<::mlir::Type> memrefTypes(&memrefRawType, 1); valueOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(valueRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); memrefOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(memrefRawOperand)) return ::mlir::failure(); if (parser.parseLSquare()) return ::mlir::failure(); indicesOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(indicesOperands)) return ::mlir::failure(); if (parser.parseRSquare()) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); memrefRawType = type; } for (::mlir::Type type : memrefTypes) { (void)type; if (!(((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { return parser.emitError(parser.getNameLoc()) << "'memref' must be memref of any non-token type values, but got " << type; } } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); if (parser.resolveOperands(valueOperands, ::llvm::cast(memrefTypes[0]).getElementType(), valueOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(memrefOperands, memrefTypes, memrefOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void StoreOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getValue(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getMemref(); _odsPrinter << "["; _odsPrinter << getIndices(); _odsPrinter << "]"; ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getNontemporalAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("nontemporal"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getMemref().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void StoreOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { { auto valueRange = getODSOperandIndexAndLength(1); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get()); } } } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::StoreOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::detail::StoreOpGenericAdaptorBase::Properties) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::TransposeOp definitions //===----------------------------------------------------------------------===// namespace detail { TransposeOpGenericAdaptorBase::TransposeOpGenericAdaptorBase(TransposeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::AffineMap TransposeOpGenericAdaptorBase::getPermutation() { auto attr = getPermutationAttr(); return attr.getValue(); } } // namespace detail TransposeOpAdaptor::TransposeOpAdaptor(TransposeOp op) : TransposeOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult TransposeOpAdaptor::verify(::mlir::Location loc) { auto tblgen_permutation = getProperties().permutation; (void)tblgen_permutation; if (!tblgen_permutation) return emitError(loc, "'memref.transpose' op requires attribute 'permutation'"); if (tblgen_permutation && !((::llvm::isa<::mlir::AffineMapAttr>(tblgen_permutation)))) return emitError(loc, "'memref.transpose' op attribute 'permutation' failed to satisfy constraint: AffineMap attribute"); return ::mlir::success(); } ::llvm::LogicalResult TransposeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.permutation; auto attr = dict.get("permutation"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `permutation` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute TransposeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.permutation; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("permutation", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code TransposeOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.permutation.getAsOpaquePointer())); } std::optional TransposeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "permutation") return prop.permutation; return std::nullopt; } void TransposeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "permutation") { prop.permutation = ::llvm::dyn_cast_or_null>(value); return; } } void TransposeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.permutation) attrs.append("permutation", prop.permutation); } ::llvm::LogicalResult TransposeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getPermutationAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps13(attr, "permutation", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult TransposeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.permutation))) return ::mlir::failure(); return ::mlir::success(); } void TransposeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.permutation); } ::mlir::AffineMap TransposeOp::getPermutation() { auto attr = getPermutationAttr(); return attr.getValue(); } void TransposeOp::setPermutation(::mlir::AffineMap attrValue) { getProperties().permutation = ::mlir::AffineMapAttr::get(attrValue); } TransposeOp TransposeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value in, AffineMapAttr permutation, ArrayRef attrs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(in), std::forward(permutation), std::forward(attrs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TransposeOp TransposeOp::create(::mlir::ImplicitLocOpBuilder &builder, Value in, AffineMapAttr permutation, ArrayRef attrs) { return create(builder, builder.getLoc(), std::forward(in), std::forward(permutation), std::forward(attrs)); } void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value in, ::mlir::AffineMapAttr permutation) { odsState.addOperands(in); odsState.getOrAddProperties().permutation = permutation; odsState.addTypes(resultType0); } TransposeOp TransposeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type resultType0, ::mlir::Value in, ::mlir::AffineMapAttr permutation) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType0), std::forward(in), std::forward(permutation)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TransposeOp TransposeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type resultType0, ::mlir::Value in, ::mlir::AffineMapAttr permutation) { return create(builder, builder.getLoc(), std::forward(resultType0), std::forward(in), std::forward(permutation)); } void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::AffineMapAttr permutation) { odsState.addOperands(in); odsState.getOrAddProperties().permutation = permutation; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } TransposeOp TransposeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::AffineMapAttr permutation) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in), std::forward(permutation)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TransposeOp TransposeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::AffineMapAttr permutation) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in), std::forward(permutation)); } void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value in, ::mlir::AffineMap permutation) { odsState.addOperands(in); odsState.getOrAddProperties().permutation = ::mlir::AffineMapAttr::get(permutation); odsState.addTypes(resultType0); } TransposeOp TransposeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type resultType0, ::mlir::Value in, ::mlir::AffineMap permutation) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType0), std::forward(in), std::forward(permutation)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TransposeOp TransposeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type resultType0, ::mlir::Value in, ::mlir::AffineMap permutation) { return create(builder, builder.getLoc(), std::forward(resultType0), std::forward(in), std::forward(permutation)); } void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::AffineMap permutation) { odsState.addOperands(in); odsState.getOrAddProperties().permutation = ::mlir::AffineMapAttr::get(permutation); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } TransposeOp TransposeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::AffineMap permutation) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in), std::forward(permutation)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TransposeOp TransposeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::AffineMap permutation) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in), std::forward(permutation)); } void TransposeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } TransposeOp TransposeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TransposeOp TransposeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void TransposeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } TransposeOp TransposeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TransposeOp TransposeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult TransposeOp::verifyInvariantsImpl() { auto tblgen_permutation = getProperties().permutation; (void)tblgen_permutation; if (!tblgen_permutation) return emitOpError("requires attribute 'permutation'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps13(*this, tblgen_permutation, "permutation"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps9(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps9(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult TransposeOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult TransposeOp::setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } // keep track of used keys in the input dictionary to be able to error out // if there are some unknown ones. ::mlir::DenseSet<::mlir::StringAttr> usedKeys; ::mlir::MLIRContext *ctx = dict.getContext(); (void)ctx; { auto &propStorage = prop.permutation; auto permutationAttrName = ::mlir::StringAttr::get(ctx, "permutation"); auto attr = dict.get(permutationAttrName); usedKeys.insert(permutationAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for permutation in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `permutation` in property conversion: " << attr; return ::mlir::failure(); } } } for (::mlir::NamedAttribute attr : dict) { if (!usedKeys.contains(attr.getName())) return emitError() << "unknown key '" << attr.getName() << "' when parsing properties dictionary"; } return ::mlir::success(); } void TransposeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::TransposeOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::detail::TransposeOpGenericAdaptorBase::Properties) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::ViewOp definitions //===----------------------------------------------------------------------===// namespace detail { ViewOpGenericAdaptorBase::ViewOpGenericAdaptorBase(ViewOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ViewOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } } // namespace detail ViewOpAdaptor::ViewOpAdaptor(ViewOp op) : ViewOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ViewOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair ViewOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange ViewOp::getSizesMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult ViewOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute ViewOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ViewOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional ViewOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void ViewOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void ViewOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult ViewOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void ViewOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value source, ::mlir::Value byte_shift, ::mlir::ValueRange sizes) { odsState.addOperands(source); odsState.addOperands(byte_shift); odsState.addOperands(sizes); odsState.addTypes(resultType0); } ViewOp ViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type resultType0, ::mlir::Value source, ::mlir::Value byte_shift, ::mlir::ValueRange sizes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType0), std::forward(source), std::forward(byte_shift), std::forward(sizes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ViewOp ViewOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type resultType0, ::mlir::Value source, ::mlir::Value byte_shift, ::mlir::ValueRange sizes) { return create(builder, builder.getLoc(), std::forward(resultType0), std::forward(source), std::forward(byte_shift), std::forward(sizes)); } void ViewOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value byte_shift, ::mlir::ValueRange sizes) { odsState.addOperands(source); odsState.addOperands(byte_shift); odsState.addOperands(sizes); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ViewOp ViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value byte_shift, ::mlir::ValueRange sizes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(source), std::forward(byte_shift), std::forward(sizes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ViewOp ViewOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value byte_shift, ::mlir::ValueRange sizes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(source), std::forward(byte_shift), std::forward(sizes)); } void ViewOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ViewOp ViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ViewOp ViewOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void ViewOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ViewOp ViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ViewOp ViewOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult ViewOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps16(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ViewOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ViewOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(&sourceRawOperand, 1); ::llvm::SMLoc sourceOperandsLoc; (void)sourceOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand byte_shiftRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> byte_shiftOperands(&byte_shiftRawOperand, 1); ::llvm::SMLoc byte_shiftOperandsLoc; (void)byte_shiftOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> sizesOperands; ::llvm::SMLoc sizesOperandsLoc; (void)sizesOperandsLoc; ::mlir::Type sourceRawType{}; ::llvm::ArrayRef<::mlir::Type> sourceTypes(&sourceRawType, 1); ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; sourceOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sourceRawOperand)) return ::mlir::failure(); if (parser.parseLSquare()) return ::mlir::failure(); byte_shiftOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(byte_shiftRawOperand)) return ::mlir::failure(); if (parser.parseRSquare()) return ::mlir::failure(); if (parser.parseLSquare()) return ::mlir::failure(); sizesOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(sizesOperands)) return ::mlir::failure(); if (parser.parseRSquare()) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); sourceRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); if (parser.parseTypeList(allResultTypes)) return ::mlir::failure(); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); result.addTypes(allResultTypes); if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(byte_shiftOperands, odsBuildableType0, byte_shiftOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(sizesOperands, odsBuildableType0, sizesOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ViewOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSource(); _odsPrinter << "["; _odsPrinter << getByteShift(); _odsPrinter << "]"; _odsPrinter << "["; _odsPrinter << getSizes(); _odsPrinter << "]"; ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSource().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; _odsPrinter << getOperation()->getResultTypes(); } void ViewOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::ViewOp) namespace mlir::memref { //===----------------------------------------------------------------------===// // ::mlir::memref::SubViewOp definitions //===----------------------------------------------------------------------===// namespace detail { SubViewOpGenericAdaptorBase::SubViewOpGenericAdaptorBase(SubViewOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair SubViewOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::llvm::ArrayRef SubViewOpGenericAdaptorBase::getStaticOffsets() { auto attr = getStaticOffsetsAttr(); return attr; } ::llvm::ArrayRef SubViewOpGenericAdaptorBase::getStaticSizes() { auto attr = getStaticSizesAttr(); return attr; } ::llvm::ArrayRef SubViewOpGenericAdaptorBase::getStaticStrides() { auto attr = getStaticStridesAttr(); return attr; } } // namespace detail SubViewOpAdaptor::SubViewOpAdaptor(SubViewOp op) : SubViewOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SubViewOpAdaptor::verify(::mlir::Location loc) { auto tblgen_static_offsets = getProperties().static_offsets; (void)tblgen_static_offsets; if (!tblgen_static_offsets) return emitError(loc, "'memref.subview' op requires attribute 'static_offsets'"); auto tblgen_static_sizes = getProperties().static_sizes; (void)tblgen_static_sizes; if (!tblgen_static_sizes) return emitError(loc, "'memref.subview' op requires attribute 'static_sizes'"); auto tblgen_static_strides = getProperties().static_strides; (void)tblgen_static_strides; if (!tblgen_static_strides) return emitError(loc, "'memref.subview' op requires attribute 'static_strides'"); if (tblgen_static_offsets && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_offsets)))) return emitError(loc, "'memref.subview' op attribute 'static_offsets' failed to satisfy constraint: i64 dense array attribute"); if (tblgen_static_sizes && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_sizes)))) return emitError(loc, "'memref.subview' op attribute 'static_sizes' failed to satisfy constraint: i64 dense array attribute"); if (tblgen_static_strides && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_strides)))) return emitError(loc, "'memref.subview' op attribute 'static_strides' failed to satisfy constraint: i64 dense array attribute"); return ::mlir::success(); } std::pair SubViewOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange SubViewOp::getOffsetsMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange SubViewOp::getSizesMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange SubViewOp::getStridesMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult SubViewOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } { auto &propStorage = prop.static_offsets; auto attr = dict.get("static_offsets"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `static_offsets` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.static_sizes; auto attr = dict.get("static_sizes"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `static_sizes` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.static_strides; auto attr = dict.get("static_strides"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `static_strides` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute SubViewOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.static_offsets; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("static_offsets", propStorage)); } { const auto &propStorage = prop.static_sizes; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("static_sizes", propStorage)); } { const auto &propStorage = prop.static_strides; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("static_strides", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code SubViewOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.static_offsets.getAsOpaquePointer()), llvm::hash_value(prop.static_sizes.getAsOpaquePointer()), llvm::hash_value(prop.static_strides.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional SubViewOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "static_offsets") return prop.static_offsets; if (name == "static_sizes") return prop.static_sizes; if (name == "static_strides") return prop.static_strides; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void SubViewOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "static_offsets") { prop.static_offsets = ::llvm::dyn_cast_or_null>(value); return; } if (name == "static_sizes") { prop.static_sizes = ::llvm::dyn_cast_or_null>(value); return; } if (name == "static_strides") { prop.static_strides = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void SubViewOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.static_offsets) attrs.append("static_offsets", prop.static_offsets); if (prop.static_sizes) attrs.append("static_sizes", prop.static_sizes); if (prop.static_strides) attrs.append("static_strides", prop.static_strides); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult SubViewOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getStaticOffsetsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps6(attr, "static_offsets", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStaticSizesAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps6(attr, "static_sizes", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStaticStridesAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps6(attr, "static_strides", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult SubViewOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readAttribute(prop.static_offsets))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.static_sizes))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.static_strides))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void SubViewOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeAttribute(prop.static_offsets); writer.writeAttribute(prop.static_sizes); writer.writeAttribute(prop.static_strides); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::llvm::ArrayRef SubViewOp::getStaticOffsets() { auto attr = getStaticOffsetsAttr(); return attr; } ::llvm::ArrayRef SubViewOp::getStaticSizes() { auto attr = getStaticSizesAttr(); return attr; } ::llvm::ArrayRef SubViewOp::getStaticStrides() { auto attr = getStaticStridesAttr(); return attr; } void SubViewOp::setStaticOffsets(::llvm::ArrayRef attrValue) { getProperties().static_offsets = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); } void SubViewOp::setStaticSizes(::llvm::ArrayRef attrValue) { getProperties().static_sizes = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); } void SubViewOp::setStaticStrides(::llvm::ArrayRef attrValue) { getProperties().static_strides = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); } SubViewOp SubViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value source, ArrayRef offsets, ArrayRef sizes, ArrayRef strides, ArrayRef attrs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(attrs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubViewOp SubViewOp::create(::mlir::ImplicitLocOpBuilder &builder, Value source, ArrayRef offsets, ArrayRef sizes, ArrayRef strides, ArrayRef attrs) { return create(builder, builder.getLoc(), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(attrs)); } SubViewOp SubViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, MemRefType resultType, Value source, ArrayRef offsets, ArrayRef sizes, ArrayRef strides, ArrayRef attrs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(attrs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubViewOp SubViewOp::create(::mlir::ImplicitLocOpBuilder &builder, MemRefType resultType, Value source, ArrayRef offsets, ArrayRef sizes, ArrayRef strides, ArrayRef attrs) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(attrs)); } SubViewOp SubViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value source, ArrayRef offsets, ArrayRef sizes, ArrayRef strides, ArrayRef attrs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(attrs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubViewOp SubViewOp::create(::mlir::ImplicitLocOpBuilder &builder, Value source, ArrayRef offsets, ArrayRef sizes, ArrayRef strides, ArrayRef attrs) { return create(builder, builder.getLoc(), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(attrs)); } SubViewOp SubViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, MemRefType resultType, Value source, ArrayRef offsets, ArrayRef sizes, ArrayRef strides, ArrayRef attrs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(attrs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubViewOp SubViewOp::create(::mlir::ImplicitLocOpBuilder &builder, MemRefType resultType, Value source, ArrayRef offsets, ArrayRef sizes, ArrayRef strides, ArrayRef attrs) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(attrs)); } SubViewOp SubViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value source, ValueRange offsets, ValueRange sizes, ValueRange strides, ArrayRef attrs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(attrs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubViewOp SubViewOp::create(::mlir::ImplicitLocOpBuilder &builder, Value source, ValueRange offsets, ValueRange sizes, ValueRange strides, ArrayRef attrs) { return create(builder, builder.getLoc(), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(attrs)); } SubViewOp SubViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, MemRefType resultType, Value source, ValueRange offsets, ValueRange sizes, ValueRange strides, ArrayRef attrs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(attrs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubViewOp SubViewOp::create(::mlir::ImplicitLocOpBuilder &builder, MemRefType resultType, Value source, ValueRange offsets, ValueRange sizes, ValueRange strides, ArrayRef attrs) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(attrs)); } void SubViewOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { odsState.addOperands(source); odsState.addOperands(offsets); odsState.addOperands(sizes); odsState.addOperands(strides); ::llvm::copy(::llvm::ArrayRef({1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().static_offsets = static_offsets; odsState.getOrAddProperties().static_sizes = static_sizes; odsState.getOrAddProperties().static_strides = static_strides; odsState.addTypes(result); } SubViewOp SubViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubViewOp SubViewOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { return create(builder, builder.getLoc(), std::forward(result), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); } void SubViewOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { odsState.addOperands(source); odsState.addOperands(offsets); odsState.addOperands(sizes); odsState.addOperands(strides); ::llvm::copy(::llvm::ArrayRef({1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().static_offsets = static_offsets; odsState.getOrAddProperties().static_sizes = static_sizes; odsState.getOrAddProperties().static_strides = static_strides; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SubViewOp SubViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubViewOp SubViewOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); } void SubViewOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { odsState.addOperands(source); odsState.addOperands(offsets); odsState.addOperands(sizes); odsState.addOperands(strides); ::llvm::copy(::llvm::ArrayRef({1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().static_offsets = odsBuilder.getDenseI64ArrayAttr(static_offsets); odsState.getOrAddProperties().static_sizes = odsBuilder.getDenseI64ArrayAttr(static_sizes); odsState.getOrAddProperties().static_strides = odsBuilder.getDenseI64ArrayAttr(static_strides); odsState.addTypes(result); } SubViewOp SubViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubViewOp SubViewOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { return create(builder, builder.getLoc(), std::forward(result), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); } void SubViewOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { odsState.addOperands(source); odsState.addOperands(offsets); odsState.addOperands(sizes); odsState.addOperands(strides); ::llvm::copy(::llvm::ArrayRef({1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().static_offsets = odsBuilder.getDenseI64ArrayAttr(static_offsets); odsState.getOrAddProperties().static_sizes = odsBuilder.getDenseI64ArrayAttr(static_sizes); odsState.getOrAddProperties().static_strides = odsBuilder.getDenseI64ArrayAttr(static_strides); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SubViewOp SubViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubViewOp SubViewOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(source), std::forward(offsets), std::forward(sizes), std::forward(strides), std::forward(static_offsets), std::forward(static_sizes), std::forward(static_strides)); } void SubViewOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } SubViewOp SubViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(attributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubViewOp SubViewOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(attributes)); } void SubViewOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } SubViewOp SubViewOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubViewOp SubViewOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operands), std::forward(properties), std::forward(discardableAttributes)); } ::llvm::LogicalResult SubViewOp::verifyInvariantsImpl() { auto tblgen_static_offsets = getProperties().static_offsets; (void)tblgen_static_offsets; if (!tblgen_static_offsets) return emitOpError("requires attribute 'static_offsets'"); auto tblgen_static_sizes = getProperties().static_sizes; (void)tblgen_static_sizes; if (!tblgen_static_sizes) return emitOpError("requires attribute 'static_sizes'"); auto tblgen_static_strides = getProperties().static_strides; (void)tblgen_static_strides; if (!tblgen_static_strides) return emitOpError("requires attribute 'static_strides'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps6(*this, tblgen_static_offsets, "static_offsets"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps6(*this, tblgen_static_sizes, "static_sizes"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_MemRefOps6(*this, tblgen_static_strides, "static_strides"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_MemRefOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult SubViewOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult SubViewOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(&sourceRawOperand, 1); ::llvm::SMLoc sourceOperandsLoc; (void)sourceOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> offsetsOperands; ::llvm::SMLoc offsetsOperandsLoc; (void)offsetsOperandsLoc; ::mlir::DenseI64ArrayAttr static_offsetsAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> sizesOperands; ::llvm::SMLoc sizesOperandsLoc; (void)sizesOperandsLoc; ::mlir::DenseI64ArrayAttr static_sizesAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> stridesOperands; ::llvm::SMLoc stridesOperandsLoc; (void)stridesOperandsLoc; ::mlir::DenseI64ArrayAttr static_stridesAttr; ::mlir::Type sourceRawType{}; ::llvm::ArrayRef<::mlir::Type> sourceTypes(&sourceRawType, 1); ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); sourceOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(sourceRawOperand)) return ::mlir::failure(); { offsetsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDynamicIndexList(parser, offsetsOperands, static_offsetsAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().static_offsets = static_offsetsAttr; } { sizesOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDynamicIndexList(parser, sizesOperands, static_sizesAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().static_sizes = static_sizesAttr; } { stridesOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDynamicIndexList(parser, stridesOperands, static_stridesAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().static_strides = static_stridesAttr; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); sourceRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::MemRefType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resultRawType = type; } ::llvm::copy(::llvm::ArrayRef({1, static_cast(offsetsOperands.size()), static_cast(sizesOperands.size()), static_cast(stridesOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); result.addTypes(resultTypes); if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(offsetsOperands, odsBuildableType0, offsetsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(sizesOperands, odsBuildableType0, sizesOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(stridesOperands, odsBuildableType0, stridesOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void SubViewOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSource(); printDynamicIndexList(_odsPrinter, *this, getOffsets(), getStaticOffsetsAttr()); _odsPrinter << ' '; printDynamicIndexList(_odsPrinter, *this, getSizes(), getStaticSizesAttr()); _odsPrinter << ' '; printDynamicIndexList(_odsPrinter, *this, getStrides(), getStaticStridesAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("static_offsets"); elidedAttrs.push_back("static_sizes"); elidedAttrs.push_back("static_strides"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSource().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getResult().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void SubViewOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::memref MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::SubViewOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::memref::detail::SubViewOpGenericAdaptorBase::Properties) #endif // GET_OP_CLASSES