/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |* *| |* Op Definitions *| |* *| |* Automatically generated file, do not edit! *| |* From: ArithOps.td *| |* *| \*===----------------------------------------------------------------------===*/ #ifdef GET_OP_LIST #undef GET_OP_LIST ::mlir::arith::AddFOp, ::mlir::arith::AddIOp, ::mlir::arith::AddUIExtendedOp, ::mlir::arith::AndIOp, ::mlir::arith::BitcastOp, ::mlir::arith::CeilDivSIOp, ::mlir::arith::CeilDivUIOp, ::mlir::arith::CmpFOp, ::mlir::arith::CmpIOp, ::mlir::arith::ConstantOp, ::mlir::arith::ConvertFOp, ::mlir::arith::DivFOp, ::mlir::arith::DivSIOp, ::mlir::arith::DivUIOp, ::mlir::arith::ExtFOp, ::mlir::arith::ExtSIOp, ::mlir::arith::ExtUIOp, ::mlir::arith::FPToSIOp, ::mlir::arith::FPToUIOp, ::mlir::arith::FloorDivSIOp, ::mlir::arith::FlushDenormalsOp, ::mlir::arith::IndexCastOp, ::mlir::arith::IndexCastUIOp, ::mlir::arith::MaxNumFOp, ::mlir::arith::MaxSIOp, ::mlir::arith::MaxUIOp, ::mlir::arith::MaximumFOp, ::mlir::arith::MinNumFOp, ::mlir::arith::MinSIOp, ::mlir::arith::MinUIOp, ::mlir::arith::MinimumFOp, ::mlir::arith::MulFOp, ::mlir::arith::MulIOp, ::mlir::arith::MulSIExtendedOp, ::mlir::arith::MulUIExtendedOp, ::mlir::arith::NegFOp, ::mlir::arith::OrIOp, ::mlir::arith::RemFOp, ::mlir::arith::RemSIOp, ::mlir::arith::RemUIOp, ::mlir::arith::SIToFPOp, ::mlir::arith::ScalingExtFOp, ::mlir::arith::ScalingTruncFOp, ::mlir::arith::ShLIOp, ::mlir::arith::ShRSIOp, ::mlir::arith::ShRUIOp, ::mlir::arith::SubFOp, ::mlir::arith::SubIOp, ::mlir::arith::SubUIExtendedOp, ::mlir::arith::TruncFOp, ::mlir::arith::TruncIOp, ::mlir::arith::UIToFPOp, ::mlir::arith::XOrIOp, ::mlir::arith::SelectOp #endif // GET_OP_LIST #ifdef GET_OP_CLASSES #undef GET_OP_CLASSES //===----------------------------------------------------------------------===// // Local Utility Method Definitions //===----------------------------------------------------------------------===// static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ArithOps1( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::FloatType>(type))) || (((type.hasTrait<::mlir::ValueSemantics>())) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::FloatType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be floating-point-like, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ArithOps2( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((((type.isSignlessInteger())) && ((!type.isInteger(0)))) || ((::llvm::isa<::mlir::IndexType>(type)))) || (((type.hasTrait<::mlir::ValueSemantics>())) && ([](::mlir::Type elementType) { return (((elementType.isSignlessInteger())) && ((!elementType.isInteger(0)))) || ((::llvm::isa<::mlir::IndexType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be signless-non-zero-bitwidth-integer-like, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ArithOps3( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((type.isSignlessInteger(1))) || (((type.hasTrait<::mlir::ValueSemantics>())) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(1)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be bool-like, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ArithOps4( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((((type.isSignlessInteger())) && ((!type.isInteger(0)))) || (((::llvm::isa<::mlir::VectorType>(type))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger())) && ((!elementType.isInteger(0))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || (((::llvm::isa<::mlir::TensorType>(type))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger())) && ((!elementType.isInteger(0))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) || (((::llvm::isa<::mlir::FloatType>(type))) || (((type.hasTrait<::mlir::ValueSemantics>())) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::FloatType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) || (((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isSignlessInteger())) && ((!elementType.isInteger(0)))) || ((::llvm::isa<::mlir::FloatType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be non-zero-bitwidth-signless-integer-or-float-like or memref of non-zero-bitwidth signless integer or float, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ArithOps5( ::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_ArithOps6( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((type.isSignlessInteger())) && ((!type.isInteger(0)))) || (((::llvm::isa<::mlir::VectorType>(type))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger())) && ((!elementType.isInteger(0))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || (((::llvm::isa<::mlir::TensorType>(type))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger())) && ((!elementType.isInteger(0))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be signless-fixed-width-integer-like, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ArithOps7( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((((((type.isSignlessInteger())) && ((!type.isInteger(0)))) || ((::llvm::isa<::mlir::IndexType>(type)))) || (((type.hasTrait<::mlir::ValueSemantics>())) && ([](::mlir::Type elementType) { return (((elementType.isSignlessInteger())) && ((!elementType.isInteger(0)))) || ((::llvm::isa<::mlir::IndexType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) || (((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isSignlessInteger())) && ((!elementType.isInteger(0)))) || ((::llvm::isa<::mlir::IndexType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be signless-non-zero-bitwidth-integer-like or memref of signless-integer, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithOps1( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Floating point fast math flags"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithOps1( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_ArithOps1(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithOps2( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::arith::RoundingModeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Floating point rounding mode"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithOps2( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_ArithOps2(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithOps3( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::arith::IntegerOverflowFlagsAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Integer overflow arith flags"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithOps3( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_ArithOps3(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithOps4( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::arith::CmpFPredicateAttr>(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_ArithOps4( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_ArithOps4(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithOps5( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::arith::CmpIPredicateAttr>(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"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithOps5( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_ArithOps5(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithOps6( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::TypedAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: TypedAttr instance"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithOps6( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_ArithOps6(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithOps7( ::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_ArithOps7( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_ArithOps7(attr, attrName, [op]() { return op->emitOpError(); }); } namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::AddFOp definitions //===----------------------------------------------------------------------===// namespace detail { AddFOpGenericAdaptorBase::AddFOpGenericAdaptorBase(AddFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::FastMathFlagsAttr AddFOpGenericAdaptorBase::getFastmathAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::FastMathFlagsAttr>(getProperties().fastmath); return attr; } ::mlir::arith::FastMathFlags AddFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } ::std::optional<::mlir::arith::RoundingMode> AddFOpGenericAdaptorBase::getRoundingmode() { auto attr = getRoundingmodeAttr(); return attr ? ::std::optional<::mlir::arith::RoundingMode>(attr.getValue()) : (::std::nullopt); } } // namespace detail AddFOpAdaptor::AddFOpAdaptor(AddFOp op) : AddFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AddFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_roundingmode = getProperties().roundingmode; (void)tblgen_roundingmode; if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.addf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); if (tblgen_roundingmode && !((::llvm::isa<::mlir::arith::RoundingModeAttr>(tblgen_roundingmode)))) return emitError(loc, "'arith.addf' op attribute 'roundingmode' failed to satisfy constraint: Floating point rounding mode"); return ::mlir::success(); } ::llvm::LogicalResult AddFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.roundingmode; auto attr = dict.get("roundingmode"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `roundingmode` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute AddFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } { const auto &propStorage = prop.roundingmode; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("roundingmode", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code AddFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer()), llvm::hash_value(prop.roundingmode.getAsOpaquePointer())); } std::optional AddFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; if (name == "roundingmode") return prop.roundingmode; return std::nullopt; } void AddFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } if (name == "roundingmode") { prop.roundingmode = ::llvm::dyn_cast_or_null>(value); return; } } void AddFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); if (prop.roundingmode) attrs.append("roundingmode", prop.roundingmode); } ::llvm::LogicalResult AddFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRoundingmodeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps2(attr, "roundingmode", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult AddFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.roundingmode))) return ::mlir::failure(); return ::mlir::success(); } void AddFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); writer.writeOptionalAttribute(prop.roundingmode); } ::mlir::arith::FastMathFlags AddFOp::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } ::std::optional<::mlir::arith::RoundingMode> AddFOp::getRoundingmode() { auto attr = getRoundingmodeAttr(); return attr ? ::std::optional<::mlir::arith::RoundingMode>(attr.getValue()) : (::std::nullopt); } void AddFOp::setFastmath(::mlir::arith::FastMathFlags attrValue) { getProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void AddFOp::setRoundingmode(::std::optional<::mlir::arith::RoundingMode> attrValue) { auto &odsProp = getProperties().roundingmode; if (attrValue) odsProp = ::mlir::arith::RoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { build(odsBuilder, odsState, lhs, rhs, fastmath, ::mlir::arith::RoundingModeAttr{}); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { build(odsBuilder, odsState, lhs, rhs, fastmath, ::mlir::arith::RoundingModeAttr{}); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value lhs, Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, Value lhs, Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type type, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { build(odsBuilder, odsState, type, lhs, rhs, ::mlir::arith::FastMathFlagsAttr::get( odsBuilder.getContext(), fastmath), ::mlir::arith::RoundingModeAttr{}); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type type, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(type), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, Type type, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(type), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } odsState.addTypes(result); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AddFOp::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); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } odsState.addTypes(result); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AddFOp::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); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AddFOp AddFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void AddFOp::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."); } } AddFOp AddFOp::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__; } AddFOp AddFOp::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 AddFOp::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(AddFOp::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)."); } } AddFOp AddFOp::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__; } AddFOp AddFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void AddFOp::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); } AddFOp AddFOp::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__; } AddFOp AddFOp::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 AddFOp::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(AddFOp::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)."); } } AddFOp AddFOp::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__; } AddFOp AddFOp::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)); } void AddFOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.fastmath) properties.fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none); } ::llvm::LogicalResult AddFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_roundingmode = getProperties().roundingmode; (void)tblgen_roundingmode; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps2(*this, tblgen_roundingmode, "roundingmode"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult AddFOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult AddFOp::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 AddFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::arith::RoundingModeAttr roundingmodeAttr; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); { ::llvm::StringRef attrStr; ::mlir::NamedAttrList attrStorage; auto loc = parser.getCurrentLocation(); if (parser.parseOptionalKeyword(&attrStr, {"to_nearest_even","downward","upward","toward_zero","to_nearest_away"})) { ::mlir::StringAttr attrVal; ::mlir::OptionalParseResult parseResult = parser.parseOptionalAttribute(attrVal, parser.getBuilder().getNoneType(), "roundingmode", attrStorage); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); attrStr = attrVal.getValue(); } else { } } if (!attrStr.empty()) { auto attrOptional = ::mlir::arith::symbolizeRoundingMode(attrStr); if (!attrOptional) return parser.emitError(loc, "invalid ") << "roundingmode attribute specification: \"" << attrStr << '"';; roundingmodeAttr = ::mlir::arith::RoundingModeAttr::get(parser.getBuilder().getContext(), *attrOptional); result.getOrAddProperties().roundingmode = roundingmodeAttr; } } if (roundingmodeAttr) { } if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void AddFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if (getRoundingmodeAttr()) { _odsPrinter << ' '; { auto caseValue = *getRoundingmode(); auto caseValueStr = stringifyRoundingMode(caseValue); _odsPrinter << caseValueStr; } } if (getFastmathAttr() != ::mlir::arith::FastMathFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::FastMathFlags::none)) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("roundingmode"); elidedAttrs.push_back("fastmath"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFastmathAttr(); if(attr && (attr == ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none))) elidedAttrs.push_back("fastmath"); } _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 AddFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::AddFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::AddFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::AddIOp definitions //===----------------------------------------------------------------------===// namespace detail { AddIOpGenericAdaptorBase::AddIOpGenericAdaptorBase(AddIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::IntegerOverflowFlagsAttr AddIOpGenericAdaptorBase::getOverflowFlagsAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::IntegerOverflowFlagsAttr>(getProperties().overflowFlags); return attr; } ::mlir::arith::IntegerOverflowFlags AddIOpGenericAdaptorBase::getOverflowFlags() { auto attr = getOverflowFlagsAttr(); return attr.getValue(); } } // namespace detail AddIOpAdaptor::AddIOpAdaptor(AddIOp op) : AddIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AddIOpAdaptor::verify(::mlir::Location loc) { auto tblgen_overflowFlags = getProperties().overflowFlags; (void)tblgen_overflowFlags; if (tblgen_overflowFlags && !((::llvm::isa<::mlir::arith::IntegerOverflowFlagsAttr>(tblgen_overflowFlags)))) return emitError(loc, "'arith.addi' op attribute 'overflowFlags' failed to satisfy constraint: Integer overflow arith flags"); return ::mlir::success(); } ::llvm::LogicalResult AddIOp::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.overflowFlags; auto attr = dict.get("overflowFlags"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `overflowFlags` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute AddIOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.overflowFlags; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("overflowFlags", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code AddIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.overflowFlags.getAsOpaquePointer())); } std::optional AddIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "overflowFlags") return prop.overflowFlags; return std::nullopt; } void AddIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "overflowFlags") { prop.overflowFlags = ::llvm::dyn_cast_or_null>(value); return; } } void AddIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.overflowFlags) attrs.append("overflowFlags", prop.overflowFlags); } ::llvm::LogicalResult AddIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getOverflowFlagsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps3(attr, "overflowFlags", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult AddIOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.overflowFlags))) return ::mlir::failure(); return ::mlir::success(); } void AddIOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.overflowFlags); } ::mlir::arith::IntegerOverflowFlags AddIOp::getOverflowFlags() { auto attr = getOverflowFlagsAttr(); return attr.getValue(); } void AddIOp::setOverflowFlags(::mlir::arith::IntegerOverflowFlags attrValue) { getProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void AddIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (overflowFlags) { odsState.getOrAddProperties().overflowFlags = overflowFlags; } odsState.addTypes(result); } AddIOp AddIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddIOp AddIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void AddIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (overflowFlags) { odsState.getOrAddProperties().overflowFlags = overflowFlags; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AddIOp::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); } AddIOp AddIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddIOp AddIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void AddIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (overflowFlags) { odsState.getOrAddProperties().overflowFlags = overflowFlags; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AddIOp AddIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddIOp AddIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void AddIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), overflowFlags); odsState.addTypes(result); } AddIOp AddIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddIOp AddIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void AddIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), overflowFlags); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AddIOp::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); } AddIOp AddIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddIOp AddIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void AddIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), overflowFlags); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AddIOp AddIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddIOp AddIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void AddIOp::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."); } } AddIOp AddIOp::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__; } AddIOp AddIOp::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 AddIOp::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(AddIOp::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)."); } } AddIOp AddIOp::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__; } AddIOp AddIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void AddIOp::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); } AddIOp AddIOp::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__; } AddIOp AddIOp::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 AddIOp::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(AddIOp::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)."); } } AddIOp AddIOp::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__; } AddIOp AddIOp::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)); } void AddIOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.overflowFlags) properties.overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::IntegerOverflowFlags::none); } ::llvm::LogicalResult AddIOp::verifyInvariantsImpl() { auto tblgen_overflowFlags = getProperties().overflowFlags; (void)tblgen_overflowFlags; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps3(*this, tblgen_overflowFlags, "overflowFlags"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult AddIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult AddIOp::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 AddIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::arith::IntegerOverflowFlagsAttr overflowFlagsAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("overflow"))) { if (parser.parseCustomAttributeWithFallback(overflowFlagsAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (overflowFlagsAttr) result.getOrAddProperties().overflowFlags = overflowFlagsAttr; } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void AddIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if (getOverflowFlagsAttr() != ::mlir::arith::IntegerOverflowFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::IntegerOverflowFlags::none)) { _odsPrinter << ' ' << "overflow"; _odsPrinter.printStrippedAttrOrType(getOverflowFlagsAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("overflowFlags"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getOverflowFlagsAttr(); if(attr && (attr == ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::IntegerOverflowFlags::none))) elidedAttrs.push_back("overflowFlags"); } _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 AddIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::AddIOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::AddIOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::AddUIExtendedOp definitions //===----------------------------------------------------------------------===// namespace detail { AddUIExtendedOpGenericAdaptorBase::AddUIExtendedOpGenericAdaptorBase(AddUIExtendedOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail AddUIExtendedOpAdaptor::AddUIExtendedOpAdaptor(AddUIExtendedOp op) : AddUIExtendedOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AddUIExtendedOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } void AddUIExtendedOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { auto resultGroup0 = getODSResults(0); if (!resultGroup0.empty()) setNameFn(*resultGroup0.begin(), "sum"); auto resultGroup1 = getODSResults(1); if (!resultGroup1.empty()) setNameFn(*resultGroup1.begin(), "overflow"); } ::llvm::LogicalResult AddUIExtendedOp::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 AddUIExtendedOp::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 AddUIExtendedOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional AddUIExtendedOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void AddUIExtendedOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void AddUIExtendedOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult AddUIExtendedOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void AddUIExtendedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs) { build(odsBuilder, odsState, lhs.getType(), ::getI1SameShape(lhs.getType()), lhs, rhs); } AddUIExtendedOp AddUIExtendedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value lhs, Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddUIExtendedOp AddUIExtendedOp::create(::mlir::ImplicitLocOpBuilder &builder, Value lhs, Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void AddUIExtendedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type sum, ::mlir::Type overflow, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(sum); odsState.addTypes(overflow); } AddUIExtendedOp AddUIExtendedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type sum, ::mlir::Type overflow, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sum), std::forward(overflow), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddUIExtendedOp AddUIExtendedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type sum, ::mlir::Type overflow, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(sum), std::forward(overflow), std::forward(lhs), std::forward(rhs)); } void AddUIExtendedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 2u && "mismatched number of results"); odsState.addTypes(resultTypes); } AddUIExtendedOp AddUIExtendedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AddUIExtendedOp AddUIExtendedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void AddUIExtendedOp::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() == 2u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AddUIExtendedOp AddUIExtendedOp::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__; } AddUIExtendedOp AddUIExtendedOp::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 AddUIExtendedOp::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() == 2u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AddUIExtendedOp AddUIExtendedOp::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__; } AddUIExtendedOp AddUIExtendedOp::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 AddUIExtendedOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSResults(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps3(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType()) && ((*this->getODSOperands(1).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 {lhs, rhs, sum} have same type"); return ::mlir::success(); } ::llvm::LogicalResult AddUIExtendedOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult AddUIExtendedOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type sumRawType{}; ::llvm::ArrayRef<::mlir::Type> sumTypes(&sumRawType, 1); ::mlir::Type overflowRawType{}; ::llvm::ArrayRef<::mlir::Type> overflowTypes(&overflowRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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(); sumRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); overflowRawType = type; } result.addTypes(sumTypes); result.addTypes(overflowTypes); if (parser.resolveOperands(lhsOperands, sumTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, sumTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void AddUIExtendedOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSum().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getOverflow().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void AddUIExtendedOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::AddUIExtendedOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::AndIOp definitions //===----------------------------------------------------------------------===// namespace detail { AndIOpGenericAdaptorBase::AndIOpGenericAdaptorBase(AndIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail AndIOpAdaptor::AndIOpAdaptor(AndIOp op) : AndIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AndIOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult AndIOp::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 AndIOp::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 AndIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional AndIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void AndIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void AndIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult AndIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void AndIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(result); } AndIOp AndIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AndIOp AndIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs)); } void AndIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(AndIOp::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); } AndIOp AndIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AndIOp AndIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void AndIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AndIOp AndIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AndIOp AndIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void AndIOp::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); } AndIOp AndIOp::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__; } AndIOp AndIOp::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 AndIOp::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(AndIOp::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)."); } } AndIOp AndIOp::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__; } AndIOp AndIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void AndIOp::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); } AndIOp AndIOp::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__; } AndIOp AndIOp::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 AndIOp::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(AndIOp::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)."); } } AndIOp AndIOp::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__; } AndIOp AndIOp::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 AndIOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult AndIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult AndIOp::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 AndIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void AndIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::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 AndIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::AndIOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::BitcastOp definitions //===----------------------------------------------------------------------===// namespace detail { BitcastOpGenericAdaptorBase::BitcastOpGenericAdaptorBase(BitcastOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail BitcastOpAdaptor::BitcastOpAdaptor(BitcastOp op) : BitcastOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult BitcastOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult BitcastOp::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 BitcastOp::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 BitcastOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional BitcastOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void BitcastOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void BitcastOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult BitcastOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void BitcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in) { odsState.addOperands(in); odsState.addTypes(out); } BitcastOp BitcastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BitcastOp BitcastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in)); } void BitcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in) { odsState.addOperands(in); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } BitcastOp BitcastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } BitcastOp BitcastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in)); } void BitcastOp::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); } BitcastOp BitcastOp::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__; } BitcastOp BitcastOp::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 BitcastOp::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); } BitcastOp BitcastOp::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__; } BitcastOp BitcastOp::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 BitcastOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps4(*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_ArithOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) && ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{}))))) return emitOpError("failed to verify that input and output have the same tensor dimensions"); return ::mlir::success(); } ::llvm::LogicalResult BitcastOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult BitcastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand inRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inOperands(&inRawOperand, 1); ::llvm::SMLoc inOperandsLoc; (void)inOperandsLoc; ::mlir::Type inRawType{}; ::llvm::ArrayRef<::mlir::Type> inTypes(&inRawType, 1); ::mlir::Type outRawType{}; ::llvm::ArrayRef<::mlir::Type> outTypes(&outRawType, 1); inOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inRawOperand)) 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(); inRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); outRawType = type; } result.addTypes(outTypes); if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void BitcastOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getIn(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getIn().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getOut().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void BitcastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::BitcastOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::CeilDivSIOp definitions //===----------------------------------------------------------------------===// namespace detail { CeilDivSIOpGenericAdaptorBase::CeilDivSIOpGenericAdaptorBase(CeilDivSIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail CeilDivSIOpAdaptor::CeilDivSIOpAdaptor(CeilDivSIOp op) : CeilDivSIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CeilDivSIOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult CeilDivSIOp::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 CeilDivSIOp::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 CeilDivSIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional CeilDivSIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void CeilDivSIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void CeilDivSIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult CeilDivSIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void CeilDivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(result); } CeilDivSIOp CeilDivSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CeilDivSIOp CeilDivSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs)); } void CeilDivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(CeilDivSIOp::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); } CeilDivSIOp CeilDivSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CeilDivSIOp CeilDivSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void CeilDivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CeilDivSIOp CeilDivSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CeilDivSIOp CeilDivSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void CeilDivSIOp::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); } CeilDivSIOp CeilDivSIOp::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__; } CeilDivSIOp CeilDivSIOp::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 CeilDivSIOp::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(CeilDivSIOp::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)."); } } CeilDivSIOp CeilDivSIOp::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__; } CeilDivSIOp CeilDivSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void CeilDivSIOp::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); } CeilDivSIOp CeilDivSIOp::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__; } CeilDivSIOp CeilDivSIOp::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 CeilDivSIOp::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(CeilDivSIOp::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)."); } } CeilDivSIOp CeilDivSIOp::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__; } CeilDivSIOp CeilDivSIOp::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 CeilDivSIOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CeilDivSIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult CeilDivSIOp::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 CeilDivSIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void CeilDivSIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::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 CeilDivSIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::CeilDivSIOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::CeilDivUIOp definitions //===----------------------------------------------------------------------===// namespace detail { CeilDivUIOpGenericAdaptorBase::CeilDivUIOpGenericAdaptorBase(CeilDivUIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail CeilDivUIOpAdaptor::CeilDivUIOpAdaptor(CeilDivUIOp op) : CeilDivUIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CeilDivUIOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult CeilDivUIOp::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 CeilDivUIOp::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 CeilDivUIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional CeilDivUIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void CeilDivUIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void CeilDivUIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult CeilDivUIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void CeilDivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(result); } CeilDivUIOp CeilDivUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CeilDivUIOp CeilDivUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs)); } void CeilDivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(CeilDivUIOp::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); } CeilDivUIOp CeilDivUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CeilDivUIOp CeilDivUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void CeilDivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CeilDivUIOp CeilDivUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CeilDivUIOp CeilDivUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void CeilDivUIOp::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); } CeilDivUIOp CeilDivUIOp::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__; } CeilDivUIOp CeilDivUIOp::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 CeilDivUIOp::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(CeilDivUIOp::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)."); } } CeilDivUIOp CeilDivUIOp::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__; } CeilDivUIOp CeilDivUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void CeilDivUIOp::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); } CeilDivUIOp CeilDivUIOp::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__; } CeilDivUIOp CeilDivUIOp::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 CeilDivUIOp::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(CeilDivUIOp::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)."); } } CeilDivUIOp CeilDivUIOp::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__; } CeilDivUIOp CeilDivUIOp::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 CeilDivUIOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CeilDivUIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult CeilDivUIOp::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 CeilDivUIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void CeilDivUIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::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 CeilDivUIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::CeilDivUIOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::CmpFOp definitions //===----------------------------------------------------------------------===// namespace detail { CmpFOpGenericAdaptorBase::CmpFOpGenericAdaptorBase(CmpFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::CmpFPredicate CmpFOpGenericAdaptorBase::getPredicate() { auto attr = getPredicateAttr(); return attr.getValue(); } ::mlir::arith::FastMathFlagsAttr CmpFOpGenericAdaptorBase::getFastmathAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::FastMathFlagsAttr>(getProperties().fastmath); return attr; } ::mlir::arith::FastMathFlags CmpFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } } // namespace detail CmpFOpAdaptor::CmpFOpAdaptor(CmpFOp op) : CmpFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CmpFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_predicate = getProperties().predicate; (void)tblgen_predicate; if (!tblgen_predicate) return emitError(loc, "'arith.cmpf' op requires attribute 'predicate'"); if (tblgen_predicate && !((::llvm::isa<::mlir::arith::CmpFPredicateAttr>(tblgen_predicate)))) return emitError(loc, "'arith.cmpf' op attribute 'predicate' 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"); if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.cmpf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); return ::mlir::success(); } ::llvm::LogicalResult CmpFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.predicate; auto attr = dict.get("predicate"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `predicate` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute CmpFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } { const auto &propStorage = prop.predicate; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("predicate", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code CmpFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer()), llvm::hash_value(prop.predicate.getAsOpaquePointer())); } std::optional CmpFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; if (name == "predicate") return prop.predicate; return std::nullopt; } void CmpFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } if (name == "predicate") { prop.predicate = ::llvm::dyn_cast_or_null>(value); return; } } void CmpFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); if (prop.predicate) attrs.append("predicate", prop.predicate); } ::llvm::LogicalResult CmpFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getPredicateAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps4(attr, "predicate", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CmpFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.predicate))) return ::mlir::failure(); return ::mlir::success(); } void CmpFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); writer.writeAttribute(prop.predicate); } ::mlir::arith::CmpFPredicate CmpFOp::getPredicate() { auto attr = getPredicateAttr(); return attr.getValue(); } ::mlir::arith::FastMathFlags CmpFOp::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } void CmpFOp::setPredicate(::mlir::arith::CmpFPredicate attrValue) { getProperties().predicate = ::mlir::arith::CmpFPredicateAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CmpFOp::setFastmath(::mlir::arith::FastMathFlags attrValue) { getProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CmpFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::arith::CmpFPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().predicate = predicate; if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } odsState.addTypes(result); } CmpFOp CmpFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::arith::CmpFPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(predicate), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CmpFOp CmpFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::arith::CmpFPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(predicate), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void CmpFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::arith::CmpFPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().predicate = predicate; if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(CmpFOp::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); } CmpFOp CmpFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::arith::CmpFPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(predicate), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CmpFOp CmpFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::arith::CmpFPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(predicate), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void CmpFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpFPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().predicate = predicate; if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CmpFOp CmpFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpFPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(predicate), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CmpFOp CmpFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpFPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(predicate), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void CmpFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::arith::CmpFPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().predicate = ::mlir::arith::CmpFPredicateAttr::get(odsBuilder.getContext(), predicate); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); odsState.addTypes(result); } CmpFOp CmpFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::arith::CmpFPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(predicate), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CmpFOp CmpFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::arith::CmpFPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(predicate), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void CmpFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::arith::CmpFPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().predicate = ::mlir::arith::CmpFPredicateAttr::get(odsBuilder.getContext(), predicate); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(CmpFOp::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); } CmpFOp CmpFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::arith::CmpFPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(predicate), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CmpFOp CmpFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::arith::CmpFPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(predicate), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void CmpFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpFPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().predicate = ::mlir::arith::CmpFPredicateAttr::get(odsBuilder.getContext(), predicate); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CmpFOp CmpFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpFPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(predicate), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CmpFOp CmpFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpFPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(predicate), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void CmpFOp::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."); } } CmpFOp CmpFOp::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__; } CmpFOp CmpFOp::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 CmpFOp::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(CmpFOp::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)."); } } CmpFOp CmpFOp::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__; } CmpFOp CmpFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void CmpFOp::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); } CmpFOp CmpFOp::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__; } CmpFOp CmpFOp::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 CmpFOp::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(CmpFOp::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)."); } } CmpFOp CmpFOp::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__; } CmpFOp CmpFOp::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)); } void CmpFOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.fastmath) properties.fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none); } ::llvm::LogicalResult CmpFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_predicate = getProperties().predicate; (void)tblgen_predicate; if (!tblgen_predicate) return emitOpError("requires attribute 'predicate'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps4(*this, tblgen_predicate, "predicate"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps3(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((std::equal_to<>()(::getI1SameShape((*this->getODSOperands(0).begin()).getType()), (*this->getODSResults(0).begin()).getType())))) return emitOpError("failed to verify that result type has i1 element type and same shape as operands"); return ::mlir::success(); } ::llvm::LogicalResult CmpFOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult CmpFOp::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 = ::getI1SameShape(operands[0].getType()); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult CmpFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::arith::CmpFPredicateAttr predicateAttr; ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type lhsRawType{}; ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); { ::llvm::StringRef attrStr; ::mlir::NamedAttrList attrStorage; auto loc = parser.getCurrentLocation(); if (parser.parseOptionalKeyword(&attrStr, {"false","oeq","ogt","oge","olt","ole","one","ord","ueq","ugt","uge","ult","ule","une","uno","true"})) { ::mlir::StringAttr attrVal; ::mlir::OptionalParseResult parseResult = parser.parseOptionalAttribute(attrVal, parser.getBuilder().getNoneType(), "predicate", 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 'predicate' [false, oeq, ogt, oge, olt, ole, one, ord, ueq, ugt, uge, ult, ule, une, uno, true]"); } } if (!attrStr.empty()) { auto attrOptional = ::mlir::arith::symbolizeCmpFPredicate(attrStr); if (!attrOptional) return parser.emitError(loc, "invalid ") << "predicate attribute specification: \"" << attrStr << '"';; predicateAttr = ::mlir::arith::CmpFPredicateAttr::get(parser.getBuilder().getContext(), *attrOptional); result.getOrAddProperties().predicate = predicateAttr; } } if (parser.parseComma()) return ::mlir::failure(); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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(); lhsRawType = type; } for (::mlir::Type type : lhsTypes) { (void)type; if (!(((::llvm::isa<::mlir::FloatType>(type))) || (((type.hasTrait<::mlir::ValueSemantics>())) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::FloatType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) { return parser.emitError(parser.getNameLoc()) << "'lhs' must be floating-point-like, but got " << type; } } result.addTypes(::getI1SameShape(lhsTypes[0])); if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, lhsTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void CmpFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; { auto caseValue = getPredicate(); auto caseValueStr = stringifyCmpFPredicate(caseValue); _odsPrinter << caseValueStr; } _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if (getFastmathAttr() != ::mlir::arith::FastMathFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::FastMathFlags::none)) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("predicate"); elidedAttrs.push_back("fastmath"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFastmathAttr(); if(attr && (attr == ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none))) elidedAttrs.push_back("fastmath"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getLhs().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void CmpFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::CmpFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::CmpFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::CmpIOp definitions //===----------------------------------------------------------------------===// namespace detail { CmpIOpGenericAdaptorBase::CmpIOpGenericAdaptorBase(CmpIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::CmpIPredicate CmpIOpGenericAdaptorBase::getPredicate() { auto attr = getPredicateAttr(); return attr.getValue(); } } // namespace detail CmpIOpAdaptor::CmpIOpAdaptor(CmpIOp op) : CmpIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CmpIOpAdaptor::verify(::mlir::Location loc) { auto tblgen_predicate = getProperties().predicate; (void)tblgen_predicate; if (!tblgen_predicate) return emitError(loc, "'arith.cmpi' op requires attribute 'predicate'"); if (tblgen_predicate && !((::llvm::isa<::mlir::arith::CmpIPredicateAttr>(tblgen_predicate)))) return emitError(loc, "'arith.cmpi' op attribute 'predicate' failed to satisfy constraint: allowed 64-bit signless integer cases: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9"); return ::mlir::success(); } ::llvm::LogicalResult CmpIOp::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.predicate; auto attr = dict.get("predicate"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `predicate` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute CmpIOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.predicate; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("predicate", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code CmpIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.predicate.getAsOpaquePointer())); } std::optional CmpIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "predicate") return prop.predicate; return std::nullopt; } void CmpIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "predicate") { prop.predicate = ::llvm::dyn_cast_or_null>(value); return; } } void CmpIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.predicate) attrs.append("predicate", prop.predicate); } ::llvm::LogicalResult CmpIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getPredicateAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps5(attr, "predicate", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CmpIOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.predicate))) return ::mlir::failure(); return ::mlir::success(); } void CmpIOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.predicate); } ::mlir::arith::CmpIPredicate CmpIOp::getPredicate() { auto attr = getPredicateAttr(); return attr.getValue(); } void CmpIOp::setPredicate(::mlir::arith::CmpIPredicate attrValue) { getProperties().predicate = ::mlir::arith::CmpIPredicateAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CmpIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::arith::CmpIPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().predicate = predicate; odsState.addTypes(result); } CmpIOp CmpIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::arith::CmpIPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(predicate), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CmpIOp CmpIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::arith::CmpIPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(result), std::forward(predicate), std::forward(lhs), std::forward(rhs)); } void CmpIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::arith::CmpIPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().predicate = predicate; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(CmpIOp::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); } CmpIOp CmpIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::arith::CmpIPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(predicate), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CmpIOp CmpIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::arith::CmpIPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(predicate), std::forward(lhs), std::forward(rhs)); } void CmpIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpIPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().predicate = predicate; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CmpIOp CmpIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpIPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(predicate), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CmpIOp CmpIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpIPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(predicate), std::forward(lhs), std::forward(rhs)); } void CmpIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::arith::CmpIPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().predicate = ::mlir::arith::CmpIPredicateAttr::get(odsBuilder.getContext(), predicate); odsState.addTypes(result); } CmpIOp CmpIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::arith::CmpIPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(predicate), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CmpIOp CmpIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::arith::CmpIPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(result), std::forward(predicate), std::forward(lhs), std::forward(rhs)); } void CmpIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::arith::CmpIPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().predicate = ::mlir::arith::CmpIPredicateAttr::get(odsBuilder.getContext(), predicate); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(CmpIOp::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); } CmpIOp CmpIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::arith::CmpIPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(predicate), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CmpIOp CmpIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::arith::CmpIPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(predicate), std::forward(lhs), std::forward(rhs)); } void CmpIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpIPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().predicate = ::mlir::arith::CmpIPredicateAttr::get(odsBuilder.getContext(), predicate); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CmpIOp CmpIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpIPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(predicate), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CmpIOp CmpIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpIPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(predicate), std::forward(lhs), std::forward(rhs)); } void CmpIOp::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."); } } CmpIOp CmpIOp::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__; } CmpIOp CmpIOp::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 CmpIOp::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(CmpIOp::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)."); } } CmpIOp CmpIOp::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__; } CmpIOp CmpIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void CmpIOp::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); } CmpIOp CmpIOp::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__; } CmpIOp CmpIOp::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 CmpIOp::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(CmpIOp::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)."); } } CmpIOp CmpIOp::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__; } CmpIOp CmpIOp::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 CmpIOp::verifyInvariantsImpl() { auto tblgen_predicate = getProperties().predicate; (void)tblgen_predicate; if (!tblgen_predicate) return emitOpError("requires attribute 'predicate'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps5(*this, tblgen_predicate, "predicate"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps3(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((std::equal_to<>()(::getI1SameShape((*this->getODSOperands(0).begin()).getType()), (*this->getODSResults(0).begin()).getType())))) return emitOpError("failed to verify that result type has i1 element type and same shape as operands"); return ::mlir::success(); } ::llvm::LogicalResult CmpIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult CmpIOp::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 = ::getI1SameShape(operands[0].getType()); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult CmpIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::arith::CmpIPredicateAttr predicateAttr; ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type lhsRawType{}; ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); { ::llvm::StringRef attrStr; ::mlir::NamedAttrList attrStorage; auto loc = parser.getCurrentLocation(); if (parser.parseOptionalKeyword(&attrStr, {"eq","ne","slt","sle","sgt","sge","ult","ule","ugt","uge"})) { ::mlir::StringAttr attrVal; ::mlir::OptionalParseResult parseResult = parser.parseOptionalAttribute(attrVal, parser.getBuilder().getNoneType(), "predicate", 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 'predicate' [eq, ne, slt, sle, sgt, sge, ult, ule, ugt, uge]"); } } if (!attrStr.empty()) { auto attrOptional = ::mlir::arith::symbolizeCmpIPredicate(attrStr); if (!attrOptional) return parser.emitError(loc, "invalid ") << "predicate attribute specification: \"" << attrStr << '"';; predicateAttr = ::mlir::arith::CmpIPredicateAttr::get(parser.getBuilder().getContext(), *attrOptional); result.getOrAddProperties().predicate = predicateAttr; } } if (parser.parseComma()) return ::mlir::failure(); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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(); lhsRawType = type; } for (::mlir::Type type : lhsTypes) { (void)type; if (!(((((type.isSignlessInteger())) && ((!type.isInteger(0)))) || ((::llvm::isa<::mlir::IndexType>(type)))) || (((type.hasTrait<::mlir::ValueSemantics>())) && ([](::mlir::Type elementType) { return (((elementType.isSignlessInteger())) && ((!elementType.isInteger(0)))) || ((::llvm::isa<::mlir::IndexType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) { return parser.emitError(parser.getNameLoc()) << "'lhs' must be signless-non-zero-bitwidth-integer-like, but got " << type; } } result.addTypes(::getI1SameShape(lhsTypes[0])); if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, lhsTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void CmpIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; { auto caseValue = getPredicate(); auto caseValueStr = stringifyCmpIPredicate(caseValue); _odsPrinter << caseValueStr; } _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("predicate"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getLhs().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void CmpIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::CmpIOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::CmpIOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::ConstantOp definitions //===----------------------------------------------------------------------===// namespace detail { ConstantOpGenericAdaptorBase::ConstantOpGenericAdaptorBase(ConstantOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::TypedAttr ConstantOpGenericAdaptorBase::getValue() { auto attr = getValueAttr(); return attr; } } // namespace detail ConstantOpAdaptor::ConstantOpAdaptor(ConstantOp op) : ConstantOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConstantOpAdaptor::verify(::mlir::Location loc) { auto tblgen_value = getProperties().value; (void)tblgen_value; if (!tblgen_value) return emitError(loc, "'arith.constant' op requires attribute 'value'"); if (tblgen_value && !((::llvm::isa<::mlir::TypedAttr>(tblgen_value)))) return emitError(loc, "'arith.constant' op attribute 'value' failed to satisfy constraint: TypedAttr instance"); return ::mlir::success(); } ::llvm::LogicalResult ConstantOp::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.value; auto attr = dict.get("value"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `value` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConstantOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.value; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("value", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConstantOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.value.getAsOpaquePointer())); } std::optional ConstantOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "value") return prop.value; return std::nullopt; } void ConstantOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "value") { prop.value = ::llvm::dyn_cast_or_null>(value); return; } } void ConstantOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.value) attrs.append("value", prop.value); } ::llvm::LogicalResult ConstantOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getValueAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps6(attr, "value", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConstantOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.value))) return ::mlir::failure(); return ::mlir::success(); } void ConstantOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.value); } ::mlir::TypedAttr ConstantOp::getValue() { auto attr = getValueAttr(); return attr; } void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::TypedAttr value) { odsState.getOrAddProperties().value = value; odsState.addTypes(result); } ConstantOp ConstantOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::TypedAttr value) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(value)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConstantOp ConstantOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::TypedAttr value) { return create(builder, builder.getLoc(), std::forward(result), std::forward(value)); } void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypedAttr value) { odsState.getOrAddProperties().value = value; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConstantOp::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); } ConstantOp ConstantOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypedAttr value) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(value)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConstantOp ConstantOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypedAttr value) { return create(builder, builder.getLoc(), std::forward(value)); } void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::TypedAttr value) { odsState.getOrAddProperties().value = value; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConstantOp ConstantOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::TypedAttr value) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(value)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConstantOp ConstantOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::TypedAttr value) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(value)); } void ConstantOp::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."); } } ConstantOp ConstantOp::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__; } ConstantOp ConstantOp::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 ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "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(ConstantOp::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)."); } } ConstantOp ConstantOp::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__; } ConstantOp ConstantOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ConstantOp::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); } ConstantOp ConstantOp::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__; } ConstantOp ConstantOp::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 ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::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); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ConstantOp::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)."); } } ConstantOp ConstantOp::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__; } ConstantOp ConstantOp::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 ConstantOp::verifyInvariantsImpl() { auto tblgen_value = getProperties().value; (void)tblgen_value; if (!tblgen_value) return emitOpError("requires attribute 'value'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps6(*this, tblgen_value, "value"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSResults(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps5(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!(((getValue().getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == (getValue().getType())))) return emitOpError("failed to verify that all of {value, result} have same type"); return ::mlir::success(); } ::llvm::LogicalResult ConstantOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ConstantOp::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::TypedAttr odsInferredTypeAttr0 = (properties ? properties.as()->value : ::llvm::dyn_cast_or_null<::mlir::TypedAttr>(attributes.get("value"))); if (!odsInferredTypeAttr0) return ::mlir::failure(); ::mlir::Type odsInferredType0 = odsInferredTypeAttr0.getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ConstantOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::TypedAttr 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(); } if (parser.parseCustomAttributeWithFallback(valueAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (valueAttr) result.getOrAddProperties().value = valueAttr; result.addTypes(valueAttr.getType()); return ::mlir::success(); } void ConstantOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("value"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getValueAttr()); } void ConstantOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::ConstantOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::ConstantOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::ConvertFOp definitions //===----------------------------------------------------------------------===// namespace detail { ConvertFOpGenericAdaptorBase::ConvertFOpGenericAdaptorBase(ConvertFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::arith::RoundingMode> ConvertFOpGenericAdaptorBase::getRoundingmode() { auto attr = getRoundingmodeAttr(); return attr ? ::std::optional<::mlir::arith::RoundingMode>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::arith::FastMathFlags> ConvertFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr ? ::std::optional<::mlir::arith::FastMathFlags>(attr.getValue()) : (::std::nullopt); } } // namespace detail ConvertFOpAdaptor::ConvertFOpAdaptor(ConvertFOp op) : ConvertFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ConvertFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_roundingmode = getProperties().roundingmode; (void)tblgen_roundingmode; if (tblgen_roundingmode && !((::llvm::isa<::mlir::arith::RoundingModeAttr>(tblgen_roundingmode)))) return emitError(loc, "'arith.convertf' op attribute 'roundingmode' failed to satisfy constraint: Floating point rounding mode"); if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.convertf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); return ::mlir::success(); } ::llvm::LogicalResult ConvertFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.roundingmode; auto attr = dict.get("roundingmode"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `roundingmode` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ConvertFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } { const auto &propStorage = prop.roundingmode; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("roundingmode", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ConvertFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer()), llvm::hash_value(prop.roundingmode.getAsOpaquePointer())); } std::optional ConvertFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; if (name == "roundingmode") return prop.roundingmode; return std::nullopt; } void ConvertFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } if (name == "roundingmode") { prop.roundingmode = ::llvm::dyn_cast_or_null>(value); return; } } void ConvertFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); if (prop.roundingmode) attrs.append("roundingmode", prop.roundingmode); } ::llvm::LogicalResult ConvertFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRoundingmodeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps2(attr, "roundingmode", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConvertFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.roundingmode))) return ::mlir::failure(); return ::mlir::success(); } void ConvertFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); writer.writeOptionalAttribute(prop.roundingmode); } ::std::optional<::mlir::arith::RoundingMode> ConvertFOp::getRoundingmode() { auto attr = getRoundingmodeAttr(); return attr ? ::std::optional<::mlir::arith::RoundingMode>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::arith::FastMathFlags> ConvertFOp::getFastmath() { auto attr = getFastmathAttr(); return attr ? ::std::optional<::mlir::arith::FastMathFlags>(attr.getValue()) : (::std::nullopt); } void ConvertFOp::setRoundingmode(::std::optional<::mlir::arith::RoundingMode> attrValue) { auto &odsProp = getProperties().roundingmode; if (attrValue) odsProp = ::mlir::arith::RoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void ConvertFOp::setFastmath(::std::optional<::mlir::arith::FastMathFlags> attrValue) { auto &odsProp = getProperties().fastmath; if (attrValue) odsProp = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void ConvertFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(in); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } odsState.addTypes(out); } ConvertFOp ConvertFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in), std::forward(roundingmode), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertFOp ConvertFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in), std::forward(roundingmode), std::forward(fastmath)); } void ConvertFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(in); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ConvertFOp ConvertFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in), std::forward(roundingmode), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ConvertFOp ConvertFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in), std::forward(roundingmode), std::forward(fastmath)); } void ConvertFOp::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."); } } ConvertFOp ConvertFOp::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__; } ConvertFOp ConvertFOp::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 ConvertFOp::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); } ConvertFOp ConvertFOp::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__; } ConvertFOp ConvertFOp::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 ConvertFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_roundingmode = getProperties().roundingmode; (void)tblgen_roundingmode; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps2(*this, tblgen_roundingmode, "roundingmode"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) && ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{}))))) return emitOpError("failed to verify that input and output have the same tensor dimensions"); return ::mlir::success(); } ::llvm::LogicalResult ConvertFOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ConvertFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand inRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inOperands(&inRawOperand, 1); ::llvm::SMLoc inOperandsLoc; (void)inOperandsLoc; ::mlir::arith::RoundingModeAttr roundingmodeAttr; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type inRawType{}; ::llvm::ArrayRef<::mlir::Type> inTypes(&inRawType, 1); ::mlir::Type outRawType{}; ::llvm::ArrayRef<::mlir::Type> outTypes(&outRawType, 1); inOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inRawOperand)) return ::mlir::failure(); { ::llvm::StringRef attrStr; ::mlir::NamedAttrList attrStorage; auto loc = parser.getCurrentLocation(); if (parser.parseOptionalKeyword(&attrStr, {"to_nearest_even","downward","upward","toward_zero","to_nearest_away"})) { ::mlir::StringAttr attrVal; ::mlir::OptionalParseResult parseResult = parser.parseOptionalAttribute(attrVal, parser.getBuilder().getNoneType(), "roundingmode", attrStorage); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); attrStr = attrVal.getValue(); } else { } } if (!attrStr.empty()) { auto attrOptional = ::mlir::arith::symbolizeRoundingMode(attrStr); if (!attrOptional) return parser.emitError(loc, "invalid ") << "roundingmode attribute specification: \"" << attrStr << '"';; roundingmodeAttr = ::mlir::arith::RoundingModeAttr::get(parser.getBuilder().getContext(), *attrOptional); result.getOrAddProperties().roundingmode = roundingmodeAttr; } } if (roundingmodeAttr) { } if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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(); inRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); outRawType = type; } result.addTypes(outTypes); if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ConvertFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getIn(); if (getRoundingmodeAttr()) { _odsPrinter << ' '; { auto caseValue = *getRoundingmode(); auto caseValueStr = stringifyRoundingMode(caseValue); _odsPrinter << caseValueStr; } } if (getFastmathAttr()) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("roundingmode"); elidedAttrs.push_back("fastmath"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getIn().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getOut().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ConvertFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::ConvertFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::ConvertFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::DivFOp definitions //===----------------------------------------------------------------------===// namespace detail { DivFOpGenericAdaptorBase::DivFOpGenericAdaptorBase(DivFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::FastMathFlagsAttr DivFOpGenericAdaptorBase::getFastmathAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::FastMathFlagsAttr>(getProperties().fastmath); return attr; } ::mlir::arith::FastMathFlags DivFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } ::std::optional<::mlir::arith::RoundingMode> DivFOpGenericAdaptorBase::getRoundingmode() { auto attr = getRoundingmodeAttr(); return attr ? ::std::optional<::mlir::arith::RoundingMode>(attr.getValue()) : (::std::nullopt); } } // namespace detail DivFOpAdaptor::DivFOpAdaptor(DivFOp op) : DivFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DivFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_roundingmode = getProperties().roundingmode; (void)tblgen_roundingmode; if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.divf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); if (tblgen_roundingmode && !((::llvm::isa<::mlir::arith::RoundingModeAttr>(tblgen_roundingmode)))) return emitError(loc, "'arith.divf' op attribute 'roundingmode' failed to satisfy constraint: Floating point rounding mode"); return ::mlir::success(); } ::llvm::LogicalResult DivFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.roundingmode; auto attr = dict.get("roundingmode"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `roundingmode` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute DivFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } { const auto &propStorage = prop.roundingmode; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("roundingmode", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DivFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer()), llvm::hash_value(prop.roundingmode.getAsOpaquePointer())); } std::optional DivFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; if (name == "roundingmode") return prop.roundingmode; return std::nullopt; } void DivFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } if (name == "roundingmode") { prop.roundingmode = ::llvm::dyn_cast_or_null>(value); return; } } void DivFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); if (prop.roundingmode) attrs.append("roundingmode", prop.roundingmode); } ::llvm::LogicalResult DivFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRoundingmodeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps2(attr, "roundingmode", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult DivFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.roundingmode))) return ::mlir::failure(); return ::mlir::success(); } void DivFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); writer.writeOptionalAttribute(prop.roundingmode); } ::mlir::arith::FastMathFlags DivFOp::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } ::std::optional<::mlir::arith::RoundingMode> DivFOp::getRoundingmode() { auto attr = getRoundingmodeAttr(); return attr ? ::std::optional<::mlir::arith::RoundingMode>(attr.getValue()) : (::std::nullopt); } void DivFOp::setFastmath(::mlir::arith::FastMathFlags attrValue) { getProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DivFOp::setRoundingmode(::std::optional<::mlir::arith::RoundingMode> attrValue) { auto &odsProp = getProperties().roundingmode; if (attrValue) odsProp = ::mlir::arith::RoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { build(odsBuilder, odsState, lhs, rhs, fastmath, ::mlir::arith::RoundingModeAttr{}); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { build(odsBuilder, odsState, lhs, rhs, fastmath, ::mlir::arith::RoundingModeAttr{}); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value lhs, Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, Value lhs, Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type type, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { build(odsBuilder, odsState, type, lhs, rhs, ::mlir::arith::FastMathFlagsAttr::get( odsBuilder.getContext(), fastmath), ::mlir::arith::RoundingModeAttr{}); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type type, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(type), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, Type type, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(type), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } odsState.addTypes(result); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DivFOp::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); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } odsState.addTypes(result); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DivFOp::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); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DivFOp DivFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void DivFOp::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."); } } DivFOp DivFOp::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__; } DivFOp DivFOp::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 DivFOp::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(DivFOp::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)."); } } DivFOp DivFOp::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__; } DivFOp DivFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void DivFOp::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); } DivFOp DivFOp::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__; } DivFOp DivFOp::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 DivFOp::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(DivFOp::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)."); } } DivFOp DivFOp::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__; } DivFOp DivFOp::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)); } void DivFOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.fastmath) properties.fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none); } ::llvm::LogicalResult DivFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_roundingmode = getProperties().roundingmode; (void)tblgen_roundingmode; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps2(*this, tblgen_roundingmode, "roundingmode"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DivFOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult DivFOp::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 DivFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::arith::RoundingModeAttr roundingmodeAttr; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); { ::llvm::StringRef attrStr; ::mlir::NamedAttrList attrStorage; auto loc = parser.getCurrentLocation(); if (parser.parseOptionalKeyword(&attrStr, {"to_nearest_even","downward","upward","toward_zero","to_nearest_away"})) { ::mlir::StringAttr attrVal; ::mlir::OptionalParseResult parseResult = parser.parseOptionalAttribute(attrVal, parser.getBuilder().getNoneType(), "roundingmode", attrStorage); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); attrStr = attrVal.getValue(); } else { } } if (!attrStr.empty()) { auto attrOptional = ::mlir::arith::symbolizeRoundingMode(attrStr); if (!attrOptional) return parser.emitError(loc, "invalid ") << "roundingmode attribute specification: \"" << attrStr << '"';; roundingmodeAttr = ::mlir::arith::RoundingModeAttr::get(parser.getBuilder().getContext(), *attrOptional); result.getOrAddProperties().roundingmode = roundingmodeAttr; } } if (roundingmodeAttr) { } if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DivFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if (getRoundingmodeAttr()) { _odsPrinter << ' '; { auto caseValue = *getRoundingmode(); auto caseValueStr = stringifyRoundingMode(caseValue); _odsPrinter << caseValueStr; } } if (getFastmathAttr() != ::mlir::arith::FastMathFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::FastMathFlags::none)) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("roundingmode"); elidedAttrs.push_back("fastmath"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFastmathAttr(); if(attr && (attr == ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none))) elidedAttrs.push_back("fastmath"); } _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 DivFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::DivFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::DivFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::DivSIOp definitions //===----------------------------------------------------------------------===// namespace detail { DivSIOpGenericAdaptorBase::DivSIOpGenericAdaptorBase(DivSIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::UnitAttr DivSIOpGenericAdaptorBase::getIsExactAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().isExact); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool DivSIOpGenericAdaptorBase::getIsExact() { auto attr = getIsExactAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail DivSIOpAdaptor::DivSIOpAdaptor(DivSIOp op) : DivSIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DivSIOpAdaptor::verify(::mlir::Location loc) { auto tblgen_isExact = getProperties().isExact; (void)tblgen_isExact; if (tblgen_isExact && !((::llvm::isa<::mlir::UnitAttr>(tblgen_isExact)))) return emitError(loc, "'arith.divsi' op attribute 'isExact' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } ::llvm::LogicalResult DivSIOp::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.isExact; auto attr = dict.get("isExact"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `isExact` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute DivSIOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.isExact; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("isExact", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DivSIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.isExact.getAsOpaquePointer())); } std::optional DivSIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "isExact") return prop.isExact; return std::nullopt; } void DivSIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "isExact") { prop.isExact = ::llvm::dyn_cast_or_null>(value); return; } } void DivSIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.isExact) attrs.append("isExact", prop.isExact); } ::llvm::LogicalResult DivSIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getIsExactAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps7(attr, "isExact", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult DivSIOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.isExact))) return ::mlir::failure(); return ::mlir::success(); } void DivSIOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.isExact); } bool DivSIOp::getIsExact() { auto attr = getIsExactAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void DivSIOp::setIsExact(bool attrValue) { auto &odsProp = getProperties().isExact; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void DivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = isExact; } odsState.addTypes(result); } DivSIOp DivSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivSIOp DivSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void DivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = isExact; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DivSIOp::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); } DivSIOp DivSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivSIOp DivSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void DivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = isExact; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DivSIOp DivSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivSIOp DivSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void DivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = ((isExact) ? odsBuilder.getUnitAttr() : nullptr); } odsState.addTypes(result); } DivSIOp DivSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivSIOp DivSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void DivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = ((isExact) ? odsBuilder.getUnitAttr() : nullptr); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DivSIOp::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); } DivSIOp DivSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivSIOp DivSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void DivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = ((isExact) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DivSIOp DivSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivSIOp DivSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void DivSIOp::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."); } } DivSIOp DivSIOp::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__; } DivSIOp DivSIOp::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 DivSIOp::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(DivSIOp::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)."); } } DivSIOp DivSIOp::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__; } DivSIOp DivSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void DivSIOp::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); } DivSIOp DivSIOp::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__; } DivSIOp DivSIOp::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 DivSIOp::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(DivSIOp::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)."); } } DivSIOp DivSIOp::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__; } DivSIOp DivSIOp::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 DivSIOp::verifyInvariantsImpl() { auto tblgen_isExact = getProperties().isExact; (void)tblgen_isExact; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps7(*this, tblgen_isExact, "isExact"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DivSIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult DivSIOp::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 DivSIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("exact"))) { result.getOrAddProperties().isExact = parser.getBuilder().getUnitAttr(); } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DivSIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if ((getIsExactAttr() && getIsExactAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "exact"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("isExact"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getIsExactAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("isExact"); } _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 DivSIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::DivSIOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::DivSIOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::DivUIOp definitions //===----------------------------------------------------------------------===// namespace detail { DivUIOpGenericAdaptorBase::DivUIOpGenericAdaptorBase(DivUIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::UnitAttr DivUIOpGenericAdaptorBase::getIsExactAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().isExact); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool DivUIOpGenericAdaptorBase::getIsExact() { auto attr = getIsExactAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail DivUIOpAdaptor::DivUIOpAdaptor(DivUIOp op) : DivUIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DivUIOpAdaptor::verify(::mlir::Location loc) { auto tblgen_isExact = getProperties().isExact; (void)tblgen_isExact; if (tblgen_isExact && !((::llvm::isa<::mlir::UnitAttr>(tblgen_isExact)))) return emitError(loc, "'arith.divui' op attribute 'isExact' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } ::llvm::LogicalResult DivUIOp::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.isExact; auto attr = dict.get("isExact"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `isExact` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute DivUIOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.isExact; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("isExact", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DivUIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.isExact.getAsOpaquePointer())); } std::optional DivUIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "isExact") return prop.isExact; return std::nullopt; } void DivUIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "isExact") { prop.isExact = ::llvm::dyn_cast_or_null>(value); return; } } void DivUIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.isExact) attrs.append("isExact", prop.isExact); } ::llvm::LogicalResult DivUIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getIsExactAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps7(attr, "isExact", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult DivUIOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.isExact))) return ::mlir::failure(); return ::mlir::success(); } void DivUIOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.isExact); } bool DivUIOp::getIsExact() { auto attr = getIsExactAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void DivUIOp::setIsExact(bool attrValue) { auto &odsProp = getProperties().isExact; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void DivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = isExact; } odsState.addTypes(result); } DivUIOp DivUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivUIOp DivUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void DivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = isExact; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DivUIOp::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); } DivUIOp DivUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivUIOp DivUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void DivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = isExact; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DivUIOp DivUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivUIOp DivUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void DivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = ((isExact) ? odsBuilder.getUnitAttr() : nullptr); } odsState.addTypes(result); } DivUIOp DivUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivUIOp DivUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void DivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = ((isExact) ? odsBuilder.getUnitAttr() : nullptr); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DivUIOp::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); } DivUIOp DivUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivUIOp DivUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void DivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = ((isExact) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DivUIOp DivUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DivUIOp DivUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void DivUIOp::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."); } } DivUIOp DivUIOp::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__; } DivUIOp DivUIOp::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 DivUIOp::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(DivUIOp::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)."); } } DivUIOp DivUIOp::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__; } DivUIOp DivUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void DivUIOp::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); } DivUIOp DivUIOp::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__; } DivUIOp DivUIOp::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 DivUIOp::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(DivUIOp::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)."); } } DivUIOp DivUIOp::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__; } DivUIOp DivUIOp::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 DivUIOp::verifyInvariantsImpl() { auto tblgen_isExact = getProperties().isExact; (void)tblgen_isExact; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps7(*this, tblgen_isExact, "isExact"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DivUIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult DivUIOp::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 DivUIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("exact"))) { result.getOrAddProperties().isExact = parser.getBuilder().getUnitAttr(); } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DivUIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if ((getIsExactAttr() && getIsExactAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "exact"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("isExact"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getIsExactAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("isExact"); } _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 DivUIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::DivUIOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::DivUIOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::ExtFOp definitions //===----------------------------------------------------------------------===// namespace detail { ExtFOpGenericAdaptorBase::ExtFOpGenericAdaptorBase(ExtFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::arith::FastMathFlags> ExtFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr ? ::std::optional<::mlir::arith::FastMathFlags>(attr.getValue()) : (::std::nullopt); } } // namespace detail ExtFOpAdaptor::ExtFOpAdaptor(ExtFOp op) : ExtFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ExtFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.extf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); return ::mlir::success(); } ::llvm::LogicalResult ExtFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ExtFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ExtFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer())); } std::optional ExtFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; return std::nullopt; } void ExtFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } } void ExtFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); } ::llvm::LogicalResult ExtFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ExtFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); return ::mlir::success(); } void ExtFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); } ::std::optional<::mlir::arith::FastMathFlags> ExtFOp::getFastmath() { auto attr = getFastmathAttr(); return attr ? ::std::optional<::mlir::arith::FastMathFlags>(attr.getValue()) : (::std::nullopt); } void ExtFOp::setFastmath(::std::optional<::mlir::arith::FastMathFlags> attrValue) { auto &odsProp = getProperties().fastmath; if (attrValue) odsProp = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void ExtFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(in); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } odsState.addTypes(out); } ExtFOp ExtFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtFOp ExtFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in), std::forward(fastmath)); } void ExtFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(in); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ExtFOp ExtFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtFOp ExtFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in), std::forward(fastmath)); } void ExtFOp::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."); } } ExtFOp ExtFOp::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__; } ExtFOp ExtFOp::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 ExtFOp::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); } ExtFOp ExtFOp::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__; } ExtFOp ExtFOp::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 ExtFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) && ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{}))))) return emitOpError("failed to verify that input and output have the same tensor dimensions"); return ::mlir::success(); } ::llvm::LogicalResult ExtFOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ExtFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand inRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inOperands(&inRawOperand, 1); ::llvm::SMLoc inOperandsLoc; (void)inOperandsLoc; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type inRawType{}; ::llvm::ArrayRef<::mlir::Type> inTypes(&inRawType, 1); ::mlir::Type outRawType{}; ::llvm::ArrayRef<::mlir::Type> outTypes(&outRawType, 1); inOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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(); inRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); outRawType = type; } result.addTypes(outTypes); if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ExtFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getIn(); if (getFastmathAttr()) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("fastmath"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getIn().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getOut().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ExtFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::ExtFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::ExtFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::ExtSIOp definitions //===----------------------------------------------------------------------===// namespace detail { ExtSIOpGenericAdaptorBase::ExtSIOpGenericAdaptorBase(ExtSIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail ExtSIOpAdaptor::ExtSIOpAdaptor(ExtSIOp op) : ExtSIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ExtSIOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult ExtSIOp::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 ExtSIOp::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 ExtSIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional ExtSIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void ExtSIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void ExtSIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult ExtSIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void ExtSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in) { odsState.addOperands(in); odsState.addTypes(out); } ExtSIOp ExtSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtSIOp ExtSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in)); } void ExtSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in) { odsState.addOperands(in); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ExtSIOp ExtSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtSIOp ExtSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in)); } void ExtSIOp::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); } ExtSIOp ExtSIOp::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__; } ExtSIOp ExtSIOp::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 ExtSIOp::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); } ExtSIOp ExtSIOp::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__; } ExtSIOp ExtSIOp::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 ExtSIOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps6(*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_ArithOps6(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) && ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{}))))) return emitOpError("failed to verify that input and output have the same tensor dimensions"); return ::mlir::success(); } ::llvm::LogicalResult ExtSIOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ExtSIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand inRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inOperands(&inRawOperand, 1); ::llvm::SMLoc inOperandsLoc; (void)inOperandsLoc; ::mlir::Type inRawType{}; ::llvm::ArrayRef<::mlir::Type> inTypes(&inRawType, 1); ::mlir::Type outRawType{}; ::llvm::ArrayRef<::mlir::Type> outTypes(&outRawType, 1); inOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inRawOperand)) 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(); inRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); outRawType = type; } result.addTypes(outTypes); if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ExtSIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getIn(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getIn().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getOut().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ExtSIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::ExtSIOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::ExtUIOp definitions //===----------------------------------------------------------------------===// namespace detail { ExtUIOpGenericAdaptorBase::ExtUIOpGenericAdaptorBase(ExtUIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::UnitAttr ExtUIOpGenericAdaptorBase::getNonNegAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nonNeg); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool ExtUIOpGenericAdaptorBase::getNonNeg() { auto attr = getNonNegAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail ExtUIOpAdaptor::ExtUIOpAdaptor(ExtUIOp op) : ExtUIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ExtUIOpAdaptor::verify(::mlir::Location loc) { auto tblgen_nonNeg = getProperties().nonNeg; (void)tblgen_nonNeg; if (tblgen_nonNeg && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nonNeg)))) return emitError(loc, "'arith.extui' op attribute 'nonNeg' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } ::llvm::LogicalResult ExtUIOp::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.nonNeg; auto attr = dict.get("nonNeg"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `nonNeg` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ExtUIOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.nonNeg; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("nonNeg", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ExtUIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.nonNeg.getAsOpaquePointer())); } std::optional ExtUIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "nonNeg") return prop.nonNeg; return std::nullopt; } void ExtUIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "nonNeg") { prop.nonNeg = ::llvm::dyn_cast_or_null>(value); return; } } void ExtUIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.nonNeg) attrs.append("nonNeg", prop.nonNeg); } ::llvm::LogicalResult ExtUIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getNonNegAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps7(attr, "nonNeg", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ExtUIOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.nonNeg))) return ::mlir::failure(); return ::mlir::success(); } void ExtUIOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.nonNeg); } bool ExtUIOp::getNonNeg() { auto attr = getNonNegAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void ExtUIOp::setNonNeg(bool attrValue) { auto &odsProp = getProperties().nonNeg; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void ExtUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { odsState.addOperands(in); if (nonNeg) { odsState.getOrAddProperties().nonNeg = nonNeg; } odsState.addTypes(out); } ExtUIOp ExtUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in), std::forward(nonNeg)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtUIOp ExtUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in), std::forward(nonNeg)); } void ExtUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { odsState.addOperands(in); if (nonNeg) { odsState.getOrAddProperties().nonNeg = nonNeg; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ExtUIOp ExtUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in), std::forward(nonNeg)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtUIOp ExtUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in), std::forward(nonNeg)); } void ExtUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in, /*optional*/bool nonNeg) { odsState.addOperands(in); if (nonNeg) { odsState.getOrAddProperties().nonNeg = ((nonNeg) ? odsBuilder.getUnitAttr() : nullptr); } odsState.addTypes(out); } ExtUIOp ExtUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in, /*optional*/bool nonNeg) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in), std::forward(nonNeg)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtUIOp ExtUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in, /*optional*/bool nonNeg) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in), std::forward(nonNeg)); } void ExtUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/bool nonNeg) { odsState.addOperands(in); if (nonNeg) { odsState.getOrAddProperties().nonNeg = ((nonNeg) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ExtUIOp ExtUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/bool nonNeg) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in), std::forward(nonNeg)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExtUIOp ExtUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/bool nonNeg) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in), std::forward(nonNeg)); } void ExtUIOp::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."); } } ExtUIOp ExtUIOp::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__; } ExtUIOp ExtUIOp::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 ExtUIOp::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); } ExtUIOp ExtUIOp::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__; } ExtUIOp ExtUIOp::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 ExtUIOp::verifyInvariantsImpl() { auto tblgen_nonNeg = getProperties().nonNeg; (void)tblgen_nonNeg; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps7(*this, tblgen_nonNeg, "nonNeg"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps6(*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_ArithOps6(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) && ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{}))))) return emitOpError("failed to verify that input and output have the same tensor dimensions"); return ::mlir::success(); } ::llvm::LogicalResult ExtUIOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ExtUIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand inRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inOperands(&inRawOperand, 1); ::llvm::SMLoc inOperandsLoc; (void)inOperandsLoc; ::mlir::Type inRawType{}; ::llvm::ArrayRef<::mlir::Type> inTypes(&inRawType, 1); ::mlir::Type outRawType{}; ::llvm::ArrayRef<::mlir::Type> outTypes(&outRawType, 1); inOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("nneg"))) { result.getOrAddProperties().nonNeg = parser.getBuilder().getUnitAttr(); } { 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(); inRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); outRawType = type; } result.addTypes(outTypes); if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ExtUIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getIn(); if ((getNonNegAttr() && getNonNegAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "nneg"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("nonNeg"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getNonNegAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("nonNeg"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getIn().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getOut().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ExtUIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::ExtUIOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::ExtUIOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::FPToSIOp definitions //===----------------------------------------------------------------------===// namespace detail { FPToSIOpGenericAdaptorBase::FPToSIOpGenericAdaptorBase(FPToSIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail FPToSIOpAdaptor::FPToSIOpAdaptor(FPToSIOp op) : FPToSIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult FPToSIOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult FPToSIOp::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 FPToSIOp::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 FPToSIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional FPToSIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void FPToSIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void FPToSIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult FPToSIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void FPToSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in) { odsState.addOperands(in); odsState.addTypes(out); } FPToSIOp FPToSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FPToSIOp FPToSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in)); } void FPToSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in) { odsState.addOperands(in); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } FPToSIOp FPToSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FPToSIOp FPToSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in)); } void FPToSIOp::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); } FPToSIOp FPToSIOp::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__; } FPToSIOp FPToSIOp::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 FPToSIOp::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); } FPToSIOp FPToSIOp::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__; } FPToSIOp FPToSIOp::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 FPToSIOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps6(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) && ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{}))))) return emitOpError("failed to verify that input and output have the same tensor dimensions"); return ::mlir::success(); } ::llvm::LogicalResult FPToSIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult FPToSIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand inRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inOperands(&inRawOperand, 1); ::llvm::SMLoc inOperandsLoc; (void)inOperandsLoc; ::mlir::Type inRawType{}; ::llvm::ArrayRef<::mlir::Type> inTypes(&inRawType, 1); ::mlir::Type outRawType{}; ::llvm::ArrayRef<::mlir::Type> outTypes(&outRawType, 1); inOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inRawOperand)) 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(); inRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); outRawType = type; } result.addTypes(outTypes); if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void FPToSIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getIn(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getIn().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getOut().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void FPToSIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::FPToSIOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::FPToUIOp definitions //===----------------------------------------------------------------------===// namespace detail { FPToUIOpGenericAdaptorBase::FPToUIOpGenericAdaptorBase(FPToUIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail FPToUIOpAdaptor::FPToUIOpAdaptor(FPToUIOp op) : FPToUIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult FPToUIOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult FPToUIOp::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 FPToUIOp::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 FPToUIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional FPToUIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void FPToUIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void FPToUIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult FPToUIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void FPToUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in) { odsState.addOperands(in); odsState.addTypes(out); } FPToUIOp FPToUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FPToUIOp FPToUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in)); } void FPToUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in) { odsState.addOperands(in); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } FPToUIOp FPToUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FPToUIOp FPToUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in)); } void FPToUIOp::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); } FPToUIOp FPToUIOp::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__; } FPToUIOp FPToUIOp::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 FPToUIOp::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); } FPToUIOp FPToUIOp::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__; } FPToUIOp FPToUIOp::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 FPToUIOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps6(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) && ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{}))))) return emitOpError("failed to verify that input and output have the same tensor dimensions"); return ::mlir::success(); } ::llvm::LogicalResult FPToUIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult FPToUIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand inRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inOperands(&inRawOperand, 1); ::llvm::SMLoc inOperandsLoc; (void)inOperandsLoc; ::mlir::Type inRawType{}; ::llvm::ArrayRef<::mlir::Type> inTypes(&inRawType, 1); ::mlir::Type outRawType{}; ::llvm::ArrayRef<::mlir::Type> outTypes(&outRawType, 1); inOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inRawOperand)) 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(); inRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); outRawType = type; } result.addTypes(outTypes); if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void FPToUIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getIn(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getIn().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getOut().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void FPToUIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::FPToUIOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::FloorDivSIOp definitions //===----------------------------------------------------------------------===// namespace detail { FloorDivSIOpGenericAdaptorBase::FloorDivSIOpGenericAdaptorBase(FloorDivSIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail FloorDivSIOpAdaptor::FloorDivSIOpAdaptor(FloorDivSIOp op) : FloorDivSIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult FloorDivSIOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult FloorDivSIOp::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 FloorDivSIOp::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 FloorDivSIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional FloorDivSIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void FloorDivSIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void FloorDivSIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult FloorDivSIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void FloorDivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(result); } FloorDivSIOp FloorDivSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FloorDivSIOp FloorDivSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs)); } void FloorDivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(FloorDivSIOp::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); } FloorDivSIOp FloorDivSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FloorDivSIOp FloorDivSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void FloorDivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } FloorDivSIOp FloorDivSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FloorDivSIOp FloorDivSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void FloorDivSIOp::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); } FloorDivSIOp FloorDivSIOp::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__; } FloorDivSIOp FloorDivSIOp::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 FloorDivSIOp::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(FloorDivSIOp::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)."); } } FloorDivSIOp FloorDivSIOp::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__; } FloorDivSIOp FloorDivSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void FloorDivSIOp::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); } FloorDivSIOp FloorDivSIOp::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__; } FloorDivSIOp FloorDivSIOp::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 FloorDivSIOp::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(FloorDivSIOp::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)."); } } FloorDivSIOp FloorDivSIOp::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__; } FloorDivSIOp FloorDivSIOp::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 FloorDivSIOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult FloorDivSIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult FloorDivSIOp::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 FloorDivSIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void FloorDivSIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::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 FloorDivSIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::FloorDivSIOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::FlushDenormalsOp definitions //===----------------------------------------------------------------------===// namespace detail { FlushDenormalsOpGenericAdaptorBase::FlushDenormalsOpGenericAdaptorBase(FlushDenormalsOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::FastMathFlagsAttr FlushDenormalsOpGenericAdaptorBase::getFastmathAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::FastMathFlagsAttr>(getProperties().fastmath); return attr; } ::mlir::arith::FastMathFlags FlushDenormalsOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } } // namespace detail FlushDenormalsOpAdaptor::FlushDenormalsOpAdaptor(FlushDenormalsOp op) : FlushDenormalsOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult FlushDenormalsOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.flush_denormals' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); return ::mlir::success(); } ::llvm::LogicalResult FlushDenormalsOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute FlushDenormalsOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code FlushDenormalsOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer())); } std::optional FlushDenormalsOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; return std::nullopt; } void FlushDenormalsOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } } void FlushDenormalsOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); } ::llvm::LogicalResult FlushDenormalsOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult FlushDenormalsOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); return ::mlir::success(); } void FlushDenormalsOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); } ::mlir::arith::FastMathFlags FlushDenormalsOp::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } void FlushDenormalsOp::setFastmath(::mlir::arith::FastMathFlags attrValue) { getProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FlushDenormalsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(operand); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } odsState.addTypes(result); } FlushDenormalsOp FlushDenormalsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(operand), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FlushDenormalsOp FlushDenormalsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(operand), std::forward(fastmath)); } void FlushDenormalsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(operand); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(FlushDenormalsOp::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); } FlushDenormalsOp FlushDenormalsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operand), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FlushDenormalsOp FlushDenormalsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(operand), std::forward(fastmath)); } void FlushDenormalsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(operand); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } FlushDenormalsOp FlushDenormalsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operand), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FlushDenormalsOp FlushDenormalsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operand), std::forward(fastmath)); } void FlushDenormalsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(operand); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); odsState.addTypes(result); } FlushDenormalsOp FlushDenormalsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(operand), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FlushDenormalsOp FlushDenormalsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(operand), std::forward(fastmath)); } void FlushDenormalsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(operand); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(FlushDenormalsOp::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); } FlushDenormalsOp FlushDenormalsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operand), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FlushDenormalsOp FlushDenormalsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(operand), std::forward(fastmath)); } void FlushDenormalsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(operand); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } FlushDenormalsOp FlushDenormalsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operand), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FlushDenormalsOp FlushDenormalsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operand), std::forward(fastmath)); } void FlushDenormalsOp::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."); } } FlushDenormalsOp FlushDenormalsOp::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__; } FlushDenormalsOp FlushDenormalsOp::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 FlushDenormalsOp::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(FlushDenormalsOp::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)."); } } FlushDenormalsOp FlushDenormalsOp::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__; } FlushDenormalsOp FlushDenormalsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void FlushDenormalsOp::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); } FlushDenormalsOp FlushDenormalsOp::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__; } FlushDenormalsOp FlushDenormalsOp::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 FlushDenormalsOp::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(FlushDenormalsOp::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)."); } } FlushDenormalsOp FlushDenormalsOp::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__; } FlushDenormalsOp FlushDenormalsOp::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)); } void FlushDenormalsOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.fastmath) properties.fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none); } ::llvm::LogicalResult FlushDenormalsOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult FlushDenormalsOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult FlushDenormalsOp::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 FlushDenormalsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; (void)operandOperandsLoc; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); operandOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(operandRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(operandOperands, resultTypes[0], operandOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void FlushDenormalsOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getOperand(); if (getFastmathAttr() != ::mlir::arith::FastMathFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::FastMathFlags::none)) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("fastmath"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFastmathAttr(); if(attr && (attr == ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none))) elidedAttrs.push_back("fastmath"); } _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 FlushDenormalsOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::FlushDenormalsOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::FlushDenormalsOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::IndexCastOp definitions //===----------------------------------------------------------------------===// namespace detail { IndexCastOpGenericAdaptorBase::IndexCastOpGenericAdaptorBase(IndexCastOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail IndexCastOpAdaptor::IndexCastOpAdaptor(IndexCastOp op) : IndexCastOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult IndexCastOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult IndexCastOp::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 IndexCastOp::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 IndexCastOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional IndexCastOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void IndexCastOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void IndexCastOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult IndexCastOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void IndexCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in) { odsState.addOperands(in); odsState.addTypes(out); } IndexCastOp IndexCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } IndexCastOp IndexCastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in)); } void IndexCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in) { odsState.addOperands(in); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } IndexCastOp IndexCastOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } IndexCastOp IndexCastOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in)); } void IndexCastOp::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); } IndexCastOp IndexCastOp::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__; } IndexCastOp IndexCastOp::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 IndexCastOp::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); } IndexCastOp IndexCastOp::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__; } IndexCastOp IndexCastOp::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 IndexCastOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps7(*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_ArithOps7(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) && ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{}))))) return emitOpError("failed to verify that input and output have the same tensor dimensions"); return ::mlir::success(); } ::llvm::LogicalResult IndexCastOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult IndexCastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand inRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inOperands(&inRawOperand, 1); ::llvm::SMLoc inOperandsLoc; (void)inOperandsLoc; ::mlir::Type inRawType{}; ::llvm::ArrayRef<::mlir::Type> inTypes(&inRawType, 1); ::mlir::Type outRawType{}; ::llvm::ArrayRef<::mlir::Type> outTypes(&outRawType, 1); inOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inRawOperand)) 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(); inRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); outRawType = type; } result.addTypes(outTypes); if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void IndexCastOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getIn(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getIn().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getOut().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void IndexCastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::IndexCastOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::IndexCastUIOp definitions //===----------------------------------------------------------------------===// namespace detail { IndexCastUIOpGenericAdaptorBase::IndexCastUIOpGenericAdaptorBase(IndexCastUIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::UnitAttr IndexCastUIOpGenericAdaptorBase::getNonNegAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nonNeg); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool IndexCastUIOpGenericAdaptorBase::getNonNeg() { auto attr = getNonNegAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail IndexCastUIOpAdaptor::IndexCastUIOpAdaptor(IndexCastUIOp op) : IndexCastUIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult IndexCastUIOpAdaptor::verify(::mlir::Location loc) { auto tblgen_nonNeg = getProperties().nonNeg; (void)tblgen_nonNeg; if (tblgen_nonNeg && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nonNeg)))) return emitError(loc, "'arith.index_castui' op attribute 'nonNeg' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } ::llvm::LogicalResult IndexCastUIOp::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.nonNeg; auto attr = dict.get("nonNeg"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `nonNeg` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute IndexCastUIOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.nonNeg; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("nonNeg", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code IndexCastUIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.nonNeg.getAsOpaquePointer())); } std::optional IndexCastUIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "nonNeg") return prop.nonNeg; return std::nullopt; } void IndexCastUIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "nonNeg") { prop.nonNeg = ::llvm::dyn_cast_or_null>(value); return; } } void IndexCastUIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.nonNeg) attrs.append("nonNeg", prop.nonNeg); } ::llvm::LogicalResult IndexCastUIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getNonNegAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps7(attr, "nonNeg", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult IndexCastUIOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.nonNeg))) return ::mlir::failure(); return ::mlir::success(); } void IndexCastUIOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.nonNeg); } bool IndexCastUIOp::getNonNeg() { auto attr = getNonNegAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void IndexCastUIOp::setNonNeg(bool attrValue) { auto &odsProp = getProperties().nonNeg; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void IndexCastUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { odsState.addOperands(in); if (nonNeg) { odsState.getOrAddProperties().nonNeg = nonNeg; } odsState.addTypes(out); } IndexCastUIOp IndexCastUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in), std::forward(nonNeg)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } IndexCastUIOp IndexCastUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in), std::forward(nonNeg)); } void IndexCastUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { odsState.addOperands(in); if (nonNeg) { odsState.getOrAddProperties().nonNeg = nonNeg; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } IndexCastUIOp IndexCastUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in), std::forward(nonNeg)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } IndexCastUIOp IndexCastUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in), std::forward(nonNeg)); } void IndexCastUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in, /*optional*/bool nonNeg) { odsState.addOperands(in); if (nonNeg) { odsState.getOrAddProperties().nonNeg = ((nonNeg) ? odsBuilder.getUnitAttr() : nullptr); } odsState.addTypes(out); } IndexCastUIOp IndexCastUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in, /*optional*/bool nonNeg) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in), std::forward(nonNeg)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } IndexCastUIOp IndexCastUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in, /*optional*/bool nonNeg) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in), std::forward(nonNeg)); } void IndexCastUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/bool nonNeg) { odsState.addOperands(in); if (nonNeg) { odsState.getOrAddProperties().nonNeg = ((nonNeg) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } IndexCastUIOp IndexCastUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/bool nonNeg) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in), std::forward(nonNeg)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } IndexCastUIOp IndexCastUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/bool nonNeg) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in), std::forward(nonNeg)); } void IndexCastUIOp::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."); } } IndexCastUIOp IndexCastUIOp::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__; } IndexCastUIOp IndexCastUIOp::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 IndexCastUIOp::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); } IndexCastUIOp IndexCastUIOp::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__; } IndexCastUIOp IndexCastUIOp::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 IndexCastUIOp::verifyInvariantsImpl() { auto tblgen_nonNeg = getProperties().nonNeg; (void)tblgen_nonNeg; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps7(*this, tblgen_nonNeg, "nonNeg"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps7(*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_ArithOps7(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) && ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{}))))) return emitOpError("failed to verify that input and output have the same tensor dimensions"); return ::mlir::success(); } ::llvm::LogicalResult IndexCastUIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult IndexCastUIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand inRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inOperands(&inRawOperand, 1); ::llvm::SMLoc inOperandsLoc; (void)inOperandsLoc; ::mlir::Type inRawType{}; ::llvm::ArrayRef<::mlir::Type> inTypes(&inRawType, 1); ::mlir::Type outRawType{}; ::llvm::ArrayRef<::mlir::Type> outTypes(&outRawType, 1); inOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("nneg"))) { result.getOrAddProperties().nonNeg = parser.getBuilder().getUnitAttr(); } { 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(); inRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); outRawType = type; } result.addTypes(outTypes); if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void IndexCastUIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getIn(); if ((getNonNegAttr() && getNonNegAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "nneg"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("nonNeg"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getNonNegAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("nonNeg"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getIn().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getOut().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void IndexCastUIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::IndexCastUIOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::IndexCastUIOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::MaxNumFOp definitions //===----------------------------------------------------------------------===// namespace detail { MaxNumFOpGenericAdaptorBase::MaxNumFOpGenericAdaptorBase(MaxNumFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::FastMathFlagsAttr MaxNumFOpGenericAdaptorBase::getFastmathAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::FastMathFlagsAttr>(getProperties().fastmath); return attr; } ::mlir::arith::FastMathFlags MaxNumFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } } // namespace detail MaxNumFOpAdaptor::MaxNumFOpAdaptor(MaxNumFOp op) : MaxNumFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MaxNumFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.maxnumf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); return ::mlir::success(); } ::llvm::LogicalResult MaxNumFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MaxNumFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MaxNumFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer())); } std::optional MaxNumFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; return std::nullopt; } void MaxNumFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } } void MaxNumFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); } ::llvm::LogicalResult MaxNumFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MaxNumFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); return ::mlir::success(); } void MaxNumFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); } ::mlir::arith::FastMathFlags MaxNumFOp::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } void MaxNumFOp::setFastmath(::mlir::arith::FastMathFlags attrValue) { getProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MaxNumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } odsState.addTypes(result); } MaxNumFOp MaxNumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaxNumFOp MaxNumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MaxNumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MaxNumFOp::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); } MaxNumFOp MaxNumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaxNumFOp MaxNumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MaxNumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MaxNumFOp MaxNumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaxNumFOp MaxNumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MaxNumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); odsState.addTypes(result); } MaxNumFOp MaxNumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaxNumFOp MaxNumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MaxNumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MaxNumFOp::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); } MaxNumFOp MaxNumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaxNumFOp MaxNumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MaxNumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MaxNumFOp MaxNumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaxNumFOp MaxNumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MaxNumFOp::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."); } } MaxNumFOp MaxNumFOp::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__; } MaxNumFOp MaxNumFOp::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 MaxNumFOp::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(MaxNumFOp::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)."); } } MaxNumFOp MaxNumFOp::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__; } MaxNumFOp MaxNumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MaxNumFOp::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); } MaxNumFOp MaxNumFOp::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__; } MaxNumFOp MaxNumFOp::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 MaxNumFOp::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(MaxNumFOp::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)."); } } MaxNumFOp MaxNumFOp::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__; } MaxNumFOp MaxNumFOp::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)); } void MaxNumFOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.fastmath) properties.fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none); } ::llvm::LogicalResult MaxNumFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MaxNumFOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult MaxNumFOp::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 MaxNumFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MaxNumFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if (getFastmathAttr() != ::mlir::arith::FastMathFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::FastMathFlags::none)) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("fastmath"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFastmathAttr(); if(attr && (attr == ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none))) elidedAttrs.push_back("fastmath"); } _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 MaxNumFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::MaxNumFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::MaxNumFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::MaxSIOp definitions //===----------------------------------------------------------------------===// namespace detail { MaxSIOpGenericAdaptorBase::MaxSIOpGenericAdaptorBase(MaxSIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail MaxSIOpAdaptor::MaxSIOpAdaptor(MaxSIOp op) : MaxSIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MaxSIOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult MaxSIOp::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 MaxSIOp::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 MaxSIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional MaxSIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void MaxSIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void MaxSIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult MaxSIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void MaxSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(result); } MaxSIOp MaxSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaxSIOp MaxSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs)); } void MaxSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MaxSIOp::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); } MaxSIOp MaxSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaxSIOp MaxSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void MaxSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MaxSIOp MaxSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaxSIOp MaxSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void MaxSIOp::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); } MaxSIOp MaxSIOp::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__; } MaxSIOp MaxSIOp::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 MaxSIOp::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(MaxSIOp::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)."); } } MaxSIOp MaxSIOp::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__; } MaxSIOp MaxSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MaxSIOp::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); } MaxSIOp MaxSIOp::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__; } MaxSIOp MaxSIOp::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 MaxSIOp::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(MaxSIOp::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)."); } } MaxSIOp MaxSIOp::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__; } MaxSIOp MaxSIOp::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 MaxSIOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MaxSIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult MaxSIOp::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 MaxSIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MaxSIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::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 MaxSIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::MaxSIOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::MaxUIOp definitions //===----------------------------------------------------------------------===// namespace detail { MaxUIOpGenericAdaptorBase::MaxUIOpGenericAdaptorBase(MaxUIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail MaxUIOpAdaptor::MaxUIOpAdaptor(MaxUIOp op) : MaxUIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MaxUIOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult MaxUIOp::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 MaxUIOp::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 MaxUIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional MaxUIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void MaxUIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void MaxUIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult MaxUIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void MaxUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(result); } MaxUIOp MaxUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaxUIOp MaxUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs)); } void MaxUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MaxUIOp::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); } MaxUIOp MaxUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaxUIOp MaxUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void MaxUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MaxUIOp MaxUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaxUIOp MaxUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void MaxUIOp::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); } MaxUIOp MaxUIOp::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__; } MaxUIOp MaxUIOp::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 MaxUIOp::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(MaxUIOp::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)."); } } MaxUIOp MaxUIOp::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__; } MaxUIOp MaxUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MaxUIOp::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); } MaxUIOp MaxUIOp::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__; } MaxUIOp MaxUIOp::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 MaxUIOp::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(MaxUIOp::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)."); } } MaxUIOp MaxUIOp::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__; } MaxUIOp MaxUIOp::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 MaxUIOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MaxUIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult MaxUIOp::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 MaxUIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MaxUIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::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 MaxUIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::MaxUIOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::MaximumFOp definitions //===----------------------------------------------------------------------===// namespace detail { MaximumFOpGenericAdaptorBase::MaximumFOpGenericAdaptorBase(MaximumFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::FastMathFlagsAttr MaximumFOpGenericAdaptorBase::getFastmathAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::FastMathFlagsAttr>(getProperties().fastmath); return attr; } ::mlir::arith::FastMathFlags MaximumFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } } // namespace detail MaximumFOpAdaptor::MaximumFOpAdaptor(MaximumFOp op) : MaximumFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MaximumFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.maximumf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); return ::mlir::success(); } ::llvm::LogicalResult MaximumFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MaximumFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MaximumFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer())); } std::optional MaximumFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; return std::nullopt; } void MaximumFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } } void MaximumFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); } ::llvm::LogicalResult MaximumFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MaximumFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); return ::mlir::success(); } void MaximumFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); } ::mlir::arith::FastMathFlags MaximumFOp::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } void MaximumFOp::setFastmath(::mlir::arith::FastMathFlags attrValue) { getProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MaximumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } odsState.addTypes(result); } MaximumFOp MaximumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaximumFOp MaximumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MaximumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MaximumFOp::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); } MaximumFOp MaximumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaximumFOp MaximumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MaximumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MaximumFOp MaximumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaximumFOp MaximumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MaximumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); odsState.addTypes(result); } MaximumFOp MaximumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaximumFOp MaximumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MaximumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MaximumFOp::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); } MaximumFOp MaximumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaximumFOp MaximumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MaximumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MaximumFOp MaximumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MaximumFOp MaximumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MaximumFOp::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."); } } MaximumFOp MaximumFOp::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__; } MaximumFOp MaximumFOp::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 MaximumFOp::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(MaximumFOp::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)."); } } MaximumFOp MaximumFOp::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__; } MaximumFOp MaximumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MaximumFOp::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); } MaximumFOp MaximumFOp::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__; } MaximumFOp MaximumFOp::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 MaximumFOp::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(MaximumFOp::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)."); } } MaximumFOp MaximumFOp::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__; } MaximumFOp MaximumFOp::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)); } void MaximumFOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.fastmath) properties.fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none); } ::llvm::LogicalResult MaximumFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MaximumFOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult MaximumFOp::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 MaximumFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MaximumFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if (getFastmathAttr() != ::mlir::arith::FastMathFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::FastMathFlags::none)) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("fastmath"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFastmathAttr(); if(attr && (attr == ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none))) elidedAttrs.push_back("fastmath"); } _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 MaximumFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::MaximumFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::MaximumFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::MinNumFOp definitions //===----------------------------------------------------------------------===// namespace detail { MinNumFOpGenericAdaptorBase::MinNumFOpGenericAdaptorBase(MinNumFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::FastMathFlagsAttr MinNumFOpGenericAdaptorBase::getFastmathAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::FastMathFlagsAttr>(getProperties().fastmath); return attr; } ::mlir::arith::FastMathFlags MinNumFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } } // namespace detail MinNumFOpAdaptor::MinNumFOpAdaptor(MinNumFOp op) : MinNumFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MinNumFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.minnumf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); return ::mlir::success(); } ::llvm::LogicalResult MinNumFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MinNumFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MinNumFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer())); } std::optional MinNumFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; return std::nullopt; } void MinNumFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } } void MinNumFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); } ::llvm::LogicalResult MinNumFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MinNumFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); return ::mlir::success(); } void MinNumFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); } ::mlir::arith::FastMathFlags MinNumFOp::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } void MinNumFOp::setFastmath(::mlir::arith::FastMathFlags attrValue) { getProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MinNumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } odsState.addTypes(result); } MinNumFOp MinNumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinNumFOp MinNumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MinNumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MinNumFOp::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); } MinNumFOp MinNumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinNumFOp MinNumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MinNumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MinNumFOp MinNumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinNumFOp MinNumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MinNumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); odsState.addTypes(result); } MinNumFOp MinNumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinNumFOp MinNumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MinNumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MinNumFOp::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); } MinNumFOp MinNumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinNumFOp MinNumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MinNumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MinNumFOp MinNumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinNumFOp MinNumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MinNumFOp::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."); } } MinNumFOp MinNumFOp::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__; } MinNumFOp MinNumFOp::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 MinNumFOp::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(MinNumFOp::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)."); } } MinNumFOp MinNumFOp::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__; } MinNumFOp MinNumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MinNumFOp::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); } MinNumFOp MinNumFOp::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__; } MinNumFOp MinNumFOp::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 MinNumFOp::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(MinNumFOp::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)."); } } MinNumFOp MinNumFOp::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__; } MinNumFOp MinNumFOp::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)); } void MinNumFOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.fastmath) properties.fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none); } ::llvm::LogicalResult MinNumFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MinNumFOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult MinNumFOp::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 MinNumFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MinNumFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if (getFastmathAttr() != ::mlir::arith::FastMathFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::FastMathFlags::none)) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("fastmath"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFastmathAttr(); if(attr && (attr == ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none))) elidedAttrs.push_back("fastmath"); } _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 MinNumFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::MinNumFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::MinNumFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::MinSIOp definitions //===----------------------------------------------------------------------===// namespace detail { MinSIOpGenericAdaptorBase::MinSIOpGenericAdaptorBase(MinSIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail MinSIOpAdaptor::MinSIOpAdaptor(MinSIOp op) : MinSIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MinSIOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult MinSIOp::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 MinSIOp::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 MinSIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional MinSIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void MinSIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void MinSIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult MinSIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void MinSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(result); } MinSIOp MinSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinSIOp MinSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs)); } void MinSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MinSIOp::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); } MinSIOp MinSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinSIOp MinSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void MinSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MinSIOp MinSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinSIOp MinSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void MinSIOp::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); } MinSIOp MinSIOp::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__; } MinSIOp MinSIOp::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 MinSIOp::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(MinSIOp::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)."); } } MinSIOp MinSIOp::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__; } MinSIOp MinSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MinSIOp::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); } MinSIOp MinSIOp::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__; } MinSIOp MinSIOp::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 MinSIOp::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(MinSIOp::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)."); } } MinSIOp MinSIOp::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__; } MinSIOp MinSIOp::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 MinSIOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MinSIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult MinSIOp::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 MinSIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MinSIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::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 MinSIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::MinSIOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::MinUIOp definitions //===----------------------------------------------------------------------===// namespace detail { MinUIOpGenericAdaptorBase::MinUIOpGenericAdaptorBase(MinUIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail MinUIOpAdaptor::MinUIOpAdaptor(MinUIOp op) : MinUIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MinUIOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult MinUIOp::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 MinUIOp::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 MinUIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional MinUIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void MinUIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void MinUIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult MinUIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void MinUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(result); } MinUIOp MinUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinUIOp MinUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs)); } void MinUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MinUIOp::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); } MinUIOp MinUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinUIOp MinUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void MinUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MinUIOp MinUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinUIOp MinUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void MinUIOp::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); } MinUIOp MinUIOp::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__; } MinUIOp MinUIOp::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 MinUIOp::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(MinUIOp::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)."); } } MinUIOp MinUIOp::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__; } MinUIOp MinUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MinUIOp::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); } MinUIOp MinUIOp::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__; } MinUIOp MinUIOp::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 MinUIOp::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(MinUIOp::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)."); } } MinUIOp MinUIOp::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__; } MinUIOp MinUIOp::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 MinUIOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MinUIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult MinUIOp::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 MinUIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MinUIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::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 MinUIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::MinUIOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::MinimumFOp definitions //===----------------------------------------------------------------------===// namespace detail { MinimumFOpGenericAdaptorBase::MinimumFOpGenericAdaptorBase(MinimumFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::FastMathFlagsAttr MinimumFOpGenericAdaptorBase::getFastmathAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::FastMathFlagsAttr>(getProperties().fastmath); return attr; } ::mlir::arith::FastMathFlags MinimumFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } } // namespace detail MinimumFOpAdaptor::MinimumFOpAdaptor(MinimumFOp op) : MinimumFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MinimumFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.minimumf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); return ::mlir::success(); } ::llvm::LogicalResult MinimumFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MinimumFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MinimumFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer())); } std::optional MinimumFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; return std::nullopt; } void MinimumFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } } void MinimumFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); } ::llvm::LogicalResult MinimumFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MinimumFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); return ::mlir::success(); } void MinimumFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); } ::mlir::arith::FastMathFlags MinimumFOp::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } void MinimumFOp::setFastmath(::mlir::arith::FastMathFlags attrValue) { getProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MinimumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } odsState.addTypes(result); } MinimumFOp MinimumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinimumFOp MinimumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MinimumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MinimumFOp::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); } MinimumFOp MinimumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinimumFOp MinimumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MinimumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MinimumFOp MinimumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinimumFOp MinimumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MinimumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); odsState.addTypes(result); } MinimumFOp MinimumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinimumFOp MinimumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MinimumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MinimumFOp::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); } MinimumFOp MinimumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinimumFOp MinimumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MinimumFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MinimumFOp MinimumFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MinimumFOp MinimumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MinimumFOp::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."); } } MinimumFOp MinimumFOp::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__; } MinimumFOp MinimumFOp::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 MinimumFOp::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(MinimumFOp::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)."); } } MinimumFOp MinimumFOp::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__; } MinimumFOp MinimumFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MinimumFOp::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); } MinimumFOp MinimumFOp::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__; } MinimumFOp MinimumFOp::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 MinimumFOp::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(MinimumFOp::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)."); } } MinimumFOp MinimumFOp::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__; } MinimumFOp MinimumFOp::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)); } void MinimumFOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.fastmath) properties.fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none); } ::llvm::LogicalResult MinimumFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MinimumFOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult MinimumFOp::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 MinimumFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MinimumFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if (getFastmathAttr() != ::mlir::arith::FastMathFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::FastMathFlags::none)) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("fastmath"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFastmathAttr(); if(attr && (attr == ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none))) elidedAttrs.push_back("fastmath"); } _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 MinimumFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::MinimumFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::MinimumFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::MulFOp definitions //===----------------------------------------------------------------------===// namespace detail { MulFOpGenericAdaptorBase::MulFOpGenericAdaptorBase(MulFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::FastMathFlagsAttr MulFOpGenericAdaptorBase::getFastmathAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::FastMathFlagsAttr>(getProperties().fastmath); return attr; } ::mlir::arith::FastMathFlags MulFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } ::std::optional<::mlir::arith::RoundingMode> MulFOpGenericAdaptorBase::getRoundingmode() { auto attr = getRoundingmodeAttr(); return attr ? ::std::optional<::mlir::arith::RoundingMode>(attr.getValue()) : (::std::nullopt); } } // namespace detail MulFOpAdaptor::MulFOpAdaptor(MulFOp op) : MulFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MulFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_roundingmode = getProperties().roundingmode; (void)tblgen_roundingmode; if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.mulf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); if (tblgen_roundingmode && !((::llvm::isa<::mlir::arith::RoundingModeAttr>(tblgen_roundingmode)))) return emitError(loc, "'arith.mulf' op attribute 'roundingmode' failed to satisfy constraint: Floating point rounding mode"); return ::mlir::success(); } ::llvm::LogicalResult MulFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.roundingmode; auto attr = dict.get("roundingmode"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `roundingmode` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MulFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } { const auto &propStorage = prop.roundingmode; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("roundingmode", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MulFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer()), llvm::hash_value(prop.roundingmode.getAsOpaquePointer())); } std::optional MulFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; if (name == "roundingmode") return prop.roundingmode; return std::nullopt; } void MulFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } if (name == "roundingmode") { prop.roundingmode = ::llvm::dyn_cast_or_null>(value); return; } } void MulFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); if (prop.roundingmode) attrs.append("roundingmode", prop.roundingmode); } ::llvm::LogicalResult MulFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRoundingmodeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps2(attr, "roundingmode", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MulFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.roundingmode))) return ::mlir::failure(); return ::mlir::success(); } void MulFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); writer.writeOptionalAttribute(prop.roundingmode); } ::mlir::arith::FastMathFlags MulFOp::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } ::std::optional<::mlir::arith::RoundingMode> MulFOp::getRoundingmode() { auto attr = getRoundingmodeAttr(); return attr ? ::std::optional<::mlir::arith::RoundingMode>(attr.getValue()) : (::std::nullopt); } void MulFOp::setFastmath(::mlir::arith::FastMathFlags attrValue) { getProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MulFOp::setRoundingmode(::std::optional<::mlir::arith::RoundingMode> attrValue) { auto &odsProp = getProperties().roundingmode; if (attrValue) odsProp = ::mlir::arith::RoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void MulFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { build(odsBuilder, odsState, lhs, rhs, fastmath, ::mlir::arith::RoundingModeAttr{}); } MulFOp MulFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulFOp MulFOp::create(::mlir::ImplicitLocOpBuilder &builder, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MulFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { build(odsBuilder, odsState, lhs, rhs, fastmath, ::mlir::arith::RoundingModeAttr{}); } MulFOp MulFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value lhs, Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulFOp MulFOp::create(::mlir::ImplicitLocOpBuilder &builder, Value lhs, Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MulFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type type, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { build(odsBuilder, odsState, type, lhs, rhs, ::mlir::arith::FastMathFlagsAttr::get( odsBuilder.getContext(), fastmath), ::mlir::arith::RoundingModeAttr{}); } MulFOp MulFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type type, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(type), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulFOp MulFOp::create(::mlir::ImplicitLocOpBuilder &builder, Type type, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(type), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void MulFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } odsState.addTypes(result); } MulFOp MulFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulFOp MulFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void MulFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MulFOp::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); } MulFOp MulFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulFOp MulFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void MulFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MulFOp MulFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulFOp MulFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void MulFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } odsState.addTypes(result); } MulFOp MulFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulFOp MulFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void MulFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MulFOp::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); } MulFOp MulFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulFOp MulFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void MulFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MulFOp MulFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulFOp MulFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void MulFOp::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."); } } MulFOp MulFOp::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__; } MulFOp MulFOp::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 MulFOp::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(MulFOp::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)."); } } MulFOp MulFOp::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__; } MulFOp MulFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MulFOp::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); } MulFOp MulFOp::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__; } MulFOp MulFOp::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 MulFOp::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(MulFOp::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)."); } } MulFOp MulFOp::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__; } MulFOp MulFOp::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)); } void MulFOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.fastmath) properties.fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none); } ::llvm::LogicalResult MulFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_roundingmode = getProperties().roundingmode; (void)tblgen_roundingmode; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps2(*this, tblgen_roundingmode, "roundingmode"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MulFOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult MulFOp::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 MulFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::arith::RoundingModeAttr roundingmodeAttr; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); { ::llvm::StringRef attrStr; ::mlir::NamedAttrList attrStorage; auto loc = parser.getCurrentLocation(); if (parser.parseOptionalKeyword(&attrStr, {"to_nearest_even","downward","upward","toward_zero","to_nearest_away"})) { ::mlir::StringAttr attrVal; ::mlir::OptionalParseResult parseResult = parser.parseOptionalAttribute(attrVal, parser.getBuilder().getNoneType(), "roundingmode", attrStorage); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); attrStr = attrVal.getValue(); } else { } } if (!attrStr.empty()) { auto attrOptional = ::mlir::arith::symbolizeRoundingMode(attrStr); if (!attrOptional) return parser.emitError(loc, "invalid ") << "roundingmode attribute specification: \"" << attrStr << '"';; roundingmodeAttr = ::mlir::arith::RoundingModeAttr::get(parser.getBuilder().getContext(), *attrOptional); result.getOrAddProperties().roundingmode = roundingmodeAttr; } } if (roundingmodeAttr) { } if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MulFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if (getRoundingmodeAttr()) { _odsPrinter << ' '; { auto caseValue = *getRoundingmode(); auto caseValueStr = stringifyRoundingMode(caseValue); _odsPrinter << caseValueStr; } } if (getFastmathAttr() != ::mlir::arith::FastMathFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::FastMathFlags::none)) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("roundingmode"); elidedAttrs.push_back("fastmath"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFastmathAttr(); if(attr && (attr == ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none))) elidedAttrs.push_back("fastmath"); } _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 MulFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::MulFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::MulFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::MulIOp definitions //===----------------------------------------------------------------------===// namespace detail { MulIOpGenericAdaptorBase::MulIOpGenericAdaptorBase(MulIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::IntegerOverflowFlagsAttr MulIOpGenericAdaptorBase::getOverflowFlagsAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::IntegerOverflowFlagsAttr>(getProperties().overflowFlags); return attr; } ::mlir::arith::IntegerOverflowFlags MulIOpGenericAdaptorBase::getOverflowFlags() { auto attr = getOverflowFlagsAttr(); return attr.getValue(); } } // namespace detail MulIOpAdaptor::MulIOpAdaptor(MulIOp op) : MulIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MulIOpAdaptor::verify(::mlir::Location loc) { auto tblgen_overflowFlags = getProperties().overflowFlags; (void)tblgen_overflowFlags; if (tblgen_overflowFlags && !((::llvm::isa<::mlir::arith::IntegerOverflowFlagsAttr>(tblgen_overflowFlags)))) return emitError(loc, "'arith.muli' op attribute 'overflowFlags' failed to satisfy constraint: Integer overflow arith flags"); return ::mlir::success(); } ::llvm::LogicalResult MulIOp::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.overflowFlags; auto attr = dict.get("overflowFlags"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `overflowFlags` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute MulIOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.overflowFlags; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("overflowFlags", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code MulIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.overflowFlags.getAsOpaquePointer())); } std::optional MulIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "overflowFlags") return prop.overflowFlags; return std::nullopt; } void MulIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "overflowFlags") { prop.overflowFlags = ::llvm::dyn_cast_or_null>(value); return; } } void MulIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.overflowFlags) attrs.append("overflowFlags", prop.overflowFlags); } ::llvm::LogicalResult MulIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getOverflowFlagsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps3(attr, "overflowFlags", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult MulIOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.overflowFlags))) return ::mlir::failure(); return ::mlir::success(); } void MulIOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.overflowFlags); } ::mlir::arith::IntegerOverflowFlags MulIOp::getOverflowFlags() { auto attr = getOverflowFlagsAttr(); return attr.getValue(); } void MulIOp::setOverflowFlags(::mlir::arith::IntegerOverflowFlags attrValue) { getProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void MulIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (overflowFlags) { odsState.getOrAddProperties().overflowFlags = overflowFlags; } odsState.addTypes(result); } MulIOp MulIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulIOp MulIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void MulIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (overflowFlags) { odsState.getOrAddProperties().overflowFlags = overflowFlags; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MulIOp::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); } MulIOp MulIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulIOp MulIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void MulIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (overflowFlags) { odsState.getOrAddProperties().overflowFlags = overflowFlags; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MulIOp MulIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulIOp MulIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void MulIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), overflowFlags); odsState.addTypes(result); } MulIOp MulIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulIOp MulIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void MulIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), overflowFlags); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MulIOp::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); } MulIOp MulIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulIOp MulIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void MulIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), overflowFlags); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } MulIOp MulIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulIOp MulIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void MulIOp::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."); } } MulIOp MulIOp::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__; } MulIOp MulIOp::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 MulIOp::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(MulIOp::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)."); } } MulIOp MulIOp::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__; } MulIOp MulIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MulIOp::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); } MulIOp MulIOp::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__; } MulIOp MulIOp::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 MulIOp::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(MulIOp::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)."); } } MulIOp MulIOp::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__; } MulIOp MulIOp::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)); } void MulIOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.overflowFlags) properties.overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::IntegerOverflowFlags::none); } ::llvm::LogicalResult MulIOp::verifyInvariantsImpl() { auto tblgen_overflowFlags = getProperties().overflowFlags; (void)tblgen_overflowFlags; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps3(*this, tblgen_overflowFlags, "overflowFlags"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult MulIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult MulIOp::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 MulIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::arith::IntegerOverflowFlagsAttr overflowFlagsAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("overflow"))) { if (parser.parseCustomAttributeWithFallback(overflowFlagsAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (overflowFlagsAttr) result.getOrAddProperties().overflowFlags = overflowFlagsAttr; } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MulIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if (getOverflowFlagsAttr() != ::mlir::arith::IntegerOverflowFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::IntegerOverflowFlags::none)) { _odsPrinter << ' ' << "overflow"; _odsPrinter.printStrippedAttrOrType(getOverflowFlagsAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("overflowFlags"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getOverflowFlagsAttr(); if(attr && (attr == ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::IntegerOverflowFlags::none))) elidedAttrs.push_back("overflowFlags"); } _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 MulIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::MulIOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::MulIOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::MulSIExtendedOp definitions //===----------------------------------------------------------------------===// namespace detail { MulSIExtendedOpGenericAdaptorBase::MulSIExtendedOpGenericAdaptorBase(MulSIExtendedOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail MulSIExtendedOpAdaptor::MulSIExtendedOpAdaptor(MulSIExtendedOp op) : MulSIExtendedOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MulSIExtendedOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } void MulSIExtendedOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { auto resultGroup0 = getODSResults(0); if (!resultGroup0.empty()) setNameFn(*resultGroup0.begin(), "low"); auto resultGroup1 = getODSResults(1); if (!resultGroup1.empty()) setNameFn(*resultGroup1.begin(), "high"); } ::llvm::LogicalResult MulSIExtendedOp::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 MulSIExtendedOp::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 MulSIExtendedOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional MulSIExtendedOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void MulSIExtendedOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void MulSIExtendedOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult MulSIExtendedOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void MulSIExtendedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type low, ::mlir::Type high, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(low); odsState.addTypes(high); } MulSIExtendedOp MulSIExtendedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type low, ::mlir::Type high, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(low), std::forward(high), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulSIExtendedOp MulSIExtendedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type low, ::mlir::Type high, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(low), std::forward(high), std::forward(lhs), std::forward(rhs)); } void MulSIExtendedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MulSIExtendedOp::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); } MulSIExtendedOp MulSIExtendedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulSIExtendedOp MulSIExtendedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void MulSIExtendedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 2u && "mismatched number of results"); odsState.addTypes(resultTypes); } MulSIExtendedOp MulSIExtendedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulSIExtendedOp MulSIExtendedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void MulSIExtendedOp::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() == 2u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MulSIExtendedOp MulSIExtendedOp::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__; } MulSIExtendedOp MulSIExtendedOp::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 MulSIExtendedOp::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(MulSIExtendedOp::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)."); } } MulSIExtendedOp MulSIExtendedOp::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__; } MulSIExtendedOp MulSIExtendedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MulSIExtendedOp::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() == 2u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MulSIExtendedOp MulSIExtendedOp::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__; } MulSIExtendedOp MulSIExtendedOp::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 MulSIExtendedOp::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(MulSIExtendedOp::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)."); } } MulSIExtendedOp MulSIExtendedOp::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__; } MulSIExtendedOp MulSIExtendedOp::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 MulSIExtendedOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSResults(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType()) && ((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSResults(1).begin()).getType()) && ((*this->getODSResults(1).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType())))) return emitOpError("failed to verify that all of {lhs, rhs, low, high} have same type"); return ::mlir::success(); } ::llvm::LogicalResult MulSIExtendedOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult MulSIExtendedOp::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(2); ::mlir::Builder odsBuilder(context); if (operands.size() <= 1) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[1].getType(); ::mlir::Type odsInferredType1 = operands[1].getType(); inferredReturnTypes[0] = odsInferredType0; inferredReturnTypes[1] = odsInferredType1; return ::mlir::success(); } ::mlir::ParseResult MulSIExtendedOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type lhsRawType{}; ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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(); lhsRawType = type; } result.addTypes(lhsTypes[0]); result.addTypes(lhsTypes[0]); if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, lhsTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MulSIExtendedOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getLhs().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void MulSIExtendedOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::MulSIExtendedOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::MulUIExtendedOp definitions //===----------------------------------------------------------------------===// namespace detail { MulUIExtendedOpGenericAdaptorBase::MulUIExtendedOpGenericAdaptorBase(MulUIExtendedOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail MulUIExtendedOpAdaptor::MulUIExtendedOpAdaptor(MulUIExtendedOp op) : MulUIExtendedOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult MulUIExtendedOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } void MulUIExtendedOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { auto resultGroup0 = getODSResults(0); if (!resultGroup0.empty()) setNameFn(*resultGroup0.begin(), "low"); auto resultGroup1 = getODSResults(1); if (!resultGroup1.empty()) setNameFn(*resultGroup1.begin(), "high"); } ::llvm::LogicalResult MulUIExtendedOp::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 MulUIExtendedOp::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 MulUIExtendedOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional MulUIExtendedOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void MulUIExtendedOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void MulUIExtendedOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult MulUIExtendedOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void MulUIExtendedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type low, ::mlir::Type high, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(low); odsState.addTypes(high); } MulUIExtendedOp MulUIExtendedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type low, ::mlir::Type high, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(low), std::forward(high), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulUIExtendedOp MulUIExtendedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type low, ::mlir::Type high, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(low), std::forward(high), std::forward(lhs), std::forward(rhs)); } void MulUIExtendedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(MulUIExtendedOp::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); } MulUIExtendedOp MulUIExtendedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulUIExtendedOp MulUIExtendedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void MulUIExtendedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 2u && "mismatched number of results"); odsState.addTypes(resultTypes); } MulUIExtendedOp MulUIExtendedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } MulUIExtendedOp MulUIExtendedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void MulUIExtendedOp::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() == 2u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MulUIExtendedOp MulUIExtendedOp::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__; } MulUIExtendedOp MulUIExtendedOp::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 MulUIExtendedOp::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(MulUIExtendedOp::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)."); } } MulUIExtendedOp MulUIExtendedOp::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__; } MulUIExtendedOp MulUIExtendedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void MulUIExtendedOp::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() == 2u && "mismatched number of return types"); odsState.addTypes(resultTypes); } MulUIExtendedOp MulUIExtendedOp::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__; } MulUIExtendedOp MulUIExtendedOp::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 MulUIExtendedOp::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(MulUIExtendedOp::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)."); } } MulUIExtendedOp MulUIExtendedOp::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__; } MulUIExtendedOp MulUIExtendedOp::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 MulUIExtendedOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSResults(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType()) && ((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSResults(1).begin()).getType()) && ((*this->getODSResults(1).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType())))) return emitOpError("failed to verify that all of {lhs, rhs, low, high} have same type"); return ::mlir::success(); } ::llvm::LogicalResult MulUIExtendedOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult MulUIExtendedOp::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(2); ::mlir::Builder odsBuilder(context); if (operands.size() <= 1) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[1].getType(); ::mlir::Type odsInferredType1 = operands[1].getType(); inferredReturnTypes[0] = odsInferredType0; inferredReturnTypes[1] = odsInferredType1; return ::mlir::success(); } ::mlir::ParseResult MulUIExtendedOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type lhsRawType{}; ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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(); lhsRawType = type; } result.addTypes(lhsTypes[0]); result.addTypes(lhsTypes[0]); if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, lhsTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void MulUIExtendedOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getLhs().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void MulUIExtendedOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::MulUIExtendedOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::NegFOp definitions //===----------------------------------------------------------------------===// namespace detail { NegFOpGenericAdaptorBase::NegFOpGenericAdaptorBase(NegFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::FastMathFlagsAttr NegFOpGenericAdaptorBase::getFastmathAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::FastMathFlagsAttr>(getProperties().fastmath); return attr; } ::mlir::arith::FastMathFlags NegFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } } // namespace detail NegFOpAdaptor::NegFOpAdaptor(NegFOp op) : NegFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult NegFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.negf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); return ::mlir::success(); } ::llvm::LogicalResult NegFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute NegFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code NegFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer())); } std::optional NegFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; return std::nullopt; } void NegFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } } void NegFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); } ::llvm::LogicalResult NegFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult NegFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); return ::mlir::success(); } void NegFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); } ::mlir::arith::FastMathFlags NegFOp::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } void NegFOp::setFastmath(::mlir::arith::FastMathFlags attrValue) { getProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void NegFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(operand); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } odsState.addTypes(result); } NegFOp NegFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(operand), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NegFOp NegFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(operand), std::forward(fastmath)); } void NegFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(operand); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(NegFOp::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); } NegFOp NegFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operand), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NegFOp NegFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(operand), std::forward(fastmath)); } void NegFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(operand); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } NegFOp NegFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operand), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NegFOp NegFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operand), std::forward(fastmath)); } void NegFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(operand); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); odsState.addTypes(result); } NegFOp NegFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(operand), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NegFOp NegFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(operand), std::forward(fastmath)); } void NegFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(operand); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(NegFOp::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); } NegFOp NegFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operand), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NegFOp NegFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(operand), std::forward(fastmath)); } void NegFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(operand); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } NegFOp NegFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(operand), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NegFOp NegFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(operand), std::forward(fastmath)); } void NegFOp::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."); } } NegFOp NegFOp::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__; } NegFOp NegFOp::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 NegFOp::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(NegFOp::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)."); } } NegFOp NegFOp::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__; } NegFOp NegFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void NegFOp::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); } NegFOp NegFOp::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__; } NegFOp NegFOp::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 NegFOp::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(NegFOp::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)."); } } NegFOp NegFOp::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__; } NegFOp NegFOp::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)); } void NegFOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.fastmath) properties.fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none); } ::llvm::LogicalResult NegFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult NegFOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult NegFOp::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 NegFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; (void)operandOperandsLoc; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); operandOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(operandRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(operandOperands, resultTypes[0], operandOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void NegFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getOperand(); if (getFastmathAttr() != ::mlir::arith::FastMathFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::FastMathFlags::none)) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("fastmath"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFastmathAttr(); if(attr && (attr == ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none))) elidedAttrs.push_back("fastmath"); } _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 NegFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::NegFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::NegFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::OrIOp definitions //===----------------------------------------------------------------------===// namespace detail { OrIOpGenericAdaptorBase::OrIOpGenericAdaptorBase(OrIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail OrIOpAdaptor::OrIOpAdaptor(OrIOp op) : OrIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult OrIOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult OrIOp::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 OrIOp::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 OrIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional OrIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void OrIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void OrIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult OrIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void OrIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(result); } OrIOp OrIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } OrIOp OrIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs)); } void OrIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(OrIOp::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); } OrIOp OrIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } OrIOp OrIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void OrIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } OrIOp OrIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } OrIOp OrIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void OrIOp::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); } OrIOp OrIOp::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__; } OrIOp OrIOp::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 OrIOp::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(OrIOp::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)."); } } OrIOp OrIOp::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__; } OrIOp OrIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void OrIOp::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); } OrIOp OrIOp::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__; } OrIOp OrIOp::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 OrIOp::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(OrIOp::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)."); } } OrIOp OrIOp::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__; } OrIOp OrIOp::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 OrIOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult OrIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult OrIOp::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 OrIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void OrIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::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 OrIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::OrIOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::RemFOp definitions //===----------------------------------------------------------------------===// namespace detail { RemFOpGenericAdaptorBase::RemFOpGenericAdaptorBase(RemFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::FastMathFlagsAttr RemFOpGenericAdaptorBase::getFastmathAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::FastMathFlagsAttr>(getProperties().fastmath); return attr; } ::mlir::arith::FastMathFlags RemFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } } // namespace detail RemFOpAdaptor::RemFOpAdaptor(RemFOp op) : RemFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult RemFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.remf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); return ::mlir::success(); } ::llvm::LogicalResult RemFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute RemFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code RemFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer())); } std::optional RemFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; return std::nullopt; } void RemFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } } void RemFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); } ::llvm::LogicalResult RemFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult RemFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); return ::mlir::success(); } void RemFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); } ::mlir::arith::FastMathFlags RemFOp::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } void RemFOp::setFastmath(::mlir::arith::FastMathFlags attrValue) { getProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void RemFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } odsState.addTypes(result); } RemFOp RemFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RemFOp RemFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void RemFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(RemFOp::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); } RemFOp RemFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RemFOp RemFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void RemFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } RemFOp RemFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RemFOp RemFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void RemFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); odsState.addTypes(result); } RemFOp RemFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RemFOp RemFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void RemFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(RemFOp::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); } RemFOp RemFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RemFOp RemFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void RemFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } RemFOp RemFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RemFOp RemFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void RemFOp::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."); } } RemFOp RemFOp::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__; } RemFOp RemFOp::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 RemFOp::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(RemFOp::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)."); } } RemFOp RemFOp::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__; } RemFOp RemFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void RemFOp::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); } RemFOp RemFOp::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__; } RemFOp RemFOp::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 RemFOp::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(RemFOp::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)."); } } RemFOp RemFOp::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__; } RemFOp RemFOp::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)); } void RemFOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.fastmath) properties.fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none); } ::llvm::LogicalResult RemFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult RemFOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult RemFOp::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 RemFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void RemFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if (getFastmathAttr() != ::mlir::arith::FastMathFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::FastMathFlags::none)) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("fastmath"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFastmathAttr(); if(attr && (attr == ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none))) elidedAttrs.push_back("fastmath"); } _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 RemFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::RemFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::RemFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::RemSIOp definitions //===----------------------------------------------------------------------===// namespace detail { RemSIOpGenericAdaptorBase::RemSIOpGenericAdaptorBase(RemSIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail RemSIOpAdaptor::RemSIOpAdaptor(RemSIOp op) : RemSIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult RemSIOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult RemSIOp::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 RemSIOp::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 RemSIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional RemSIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void RemSIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void RemSIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult RemSIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void RemSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(result); } RemSIOp RemSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RemSIOp RemSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs)); } void RemSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(RemSIOp::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); } RemSIOp RemSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RemSIOp RemSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void RemSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } RemSIOp RemSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RemSIOp RemSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void RemSIOp::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); } RemSIOp RemSIOp::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__; } RemSIOp RemSIOp::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 RemSIOp::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(RemSIOp::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)."); } } RemSIOp RemSIOp::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__; } RemSIOp RemSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void RemSIOp::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); } RemSIOp RemSIOp::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__; } RemSIOp RemSIOp::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 RemSIOp::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(RemSIOp::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)."); } } RemSIOp RemSIOp::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__; } RemSIOp RemSIOp::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 RemSIOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult RemSIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult RemSIOp::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 RemSIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void RemSIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::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 RemSIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::RemSIOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::RemUIOp definitions //===----------------------------------------------------------------------===// namespace detail { RemUIOpGenericAdaptorBase::RemUIOpGenericAdaptorBase(RemUIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail RemUIOpAdaptor::RemUIOpAdaptor(RemUIOp op) : RemUIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult RemUIOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult RemUIOp::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 RemUIOp::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 RemUIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional RemUIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void RemUIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void RemUIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult RemUIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void RemUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(result); } RemUIOp RemUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RemUIOp RemUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs)); } void RemUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(RemUIOp::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); } RemUIOp RemUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RemUIOp RemUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void RemUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } RemUIOp RemUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RemUIOp RemUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void RemUIOp::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); } RemUIOp RemUIOp::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__; } RemUIOp RemUIOp::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 RemUIOp::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(RemUIOp::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)."); } } RemUIOp RemUIOp::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__; } RemUIOp RemUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void RemUIOp::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); } RemUIOp RemUIOp::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__; } RemUIOp RemUIOp::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 RemUIOp::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(RemUIOp::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)."); } } RemUIOp RemUIOp::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__; } RemUIOp RemUIOp::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 RemUIOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult RemUIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult RemUIOp::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 RemUIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void RemUIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::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 RemUIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::RemUIOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::SIToFPOp definitions //===----------------------------------------------------------------------===// namespace detail { SIToFPOpGenericAdaptorBase::SIToFPOpGenericAdaptorBase(SIToFPOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail SIToFPOpAdaptor::SIToFPOpAdaptor(SIToFPOp op) : SIToFPOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SIToFPOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult SIToFPOp::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 SIToFPOp::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 SIToFPOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional SIToFPOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void SIToFPOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void SIToFPOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult SIToFPOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void SIToFPOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in) { odsState.addOperands(in); odsState.addTypes(out); } SIToFPOp SIToFPOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SIToFPOp SIToFPOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in)); } void SIToFPOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in) { odsState.addOperands(in); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SIToFPOp SIToFPOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SIToFPOp SIToFPOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in)); } void SIToFPOp::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); } SIToFPOp SIToFPOp::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__; } SIToFPOp SIToFPOp::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 SIToFPOp::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); } SIToFPOp SIToFPOp::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__; } SIToFPOp SIToFPOp::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 SIToFPOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps6(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) && ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{}))))) return emitOpError("failed to verify that input and output have the same tensor dimensions"); return ::mlir::success(); } ::llvm::LogicalResult SIToFPOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult SIToFPOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand inRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inOperands(&inRawOperand, 1); ::llvm::SMLoc inOperandsLoc; (void)inOperandsLoc; ::mlir::Type inRawType{}; ::llvm::ArrayRef<::mlir::Type> inTypes(&inRawType, 1); ::mlir::Type outRawType{}; ::llvm::ArrayRef<::mlir::Type> outTypes(&outRawType, 1); inOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inRawOperand)) 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(); inRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); outRawType = type; } result.addTypes(outTypes); if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void SIToFPOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getIn(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getIn().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getOut().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void SIToFPOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::SIToFPOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::ScalingExtFOp definitions //===----------------------------------------------------------------------===// namespace detail { ScalingExtFOpGenericAdaptorBase::ScalingExtFOpGenericAdaptorBase(ScalingExtFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::arith::FastMathFlags> ScalingExtFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr ? ::std::optional<::mlir::arith::FastMathFlags>(attr.getValue()) : (::std::nullopt); } } // namespace detail ScalingExtFOpAdaptor::ScalingExtFOpAdaptor(ScalingExtFOp op) : ScalingExtFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ScalingExtFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.scaling_extf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); return ::mlir::success(); } ::llvm::LogicalResult ScalingExtFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ScalingExtFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ScalingExtFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer())); } std::optional ScalingExtFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; return std::nullopt; } void ScalingExtFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } } void ScalingExtFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); } ::llvm::LogicalResult ScalingExtFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ScalingExtFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); return ::mlir::success(); } void ScalingExtFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); } ::std::optional<::mlir::arith::FastMathFlags> ScalingExtFOp::getFastmath() { auto attr = getFastmathAttr(); return attr ? ::std::optional<::mlir::arith::FastMathFlags>(attr.getValue()) : (::std::nullopt); } void ScalingExtFOp::setFastmath(::std::optional<::mlir::arith::FastMathFlags> attrValue) { auto &odsProp = getProperties().fastmath; if (attrValue) odsProp = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void ScalingExtFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in, ::mlir::Value scale, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(in); odsState.addOperands(scale); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } odsState.addTypes(out); } ScalingExtFOp ScalingExtFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in, ::mlir::Value scale, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in), std::forward(scale), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ScalingExtFOp ScalingExtFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in, ::mlir::Value scale, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in), std::forward(scale), std::forward(fastmath)); } void ScalingExtFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::Value scale, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(in); odsState.addOperands(scale); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ScalingExtFOp ScalingExtFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::Value scale, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in), std::forward(scale), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ScalingExtFOp ScalingExtFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::Value scale, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in), std::forward(scale), std::forward(fastmath)); } void ScalingExtFOp::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."); } } ScalingExtFOp ScalingExtFOp::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__; } ScalingExtFOp ScalingExtFOp::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 ScalingExtFOp::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); } ScalingExtFOp ScalingExtFOp::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__; } ScalingExtFOp ScalingExtFOp::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 ScalingExtFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) && ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{}))))) return emitOpError("failed to verify that input and output have the same tensor dimensions"); return ::mlir::success(); } ::llvm::LogicalResult ScalingExtFOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ScalingExtFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand inRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inOperands(&inRawOperand, 1); ::llvm::SMLoc inOperandsLoc; (void)inOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand scaleRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> scaleOperands(&scaleRawOperand, 1); ::llvm::SMLoc scaleOperandsLoc; (void)scaleOperandsLoc; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type inRawType{}; ::llvm::ArrayRef<::mlir::Type> inTypes(&inRawType, 1); ::mlir::Type scaleRawType{}; ::llvm::ArrayRef<::mlir::Type> scaleTypes(&scaleRawType, 1); ::mlir::Type outRawType{}; ::llvm::ArrayRef<::mlir::Type> outTypes(&outRawType, 1); inOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); scaleOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(scaleRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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(); inRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); scaleRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); outRawType = type; } result.addTypes(outTypes); if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(scaleOperands, scaleTypes, scaleOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ScalingExtFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getIn(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getScale(); if (getFastmathAttr()) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("fastmath"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getIn().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getScale().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getOut().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ScalingExtFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::ScalingExtFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::ScalingExtFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::ScalingTruncFOp definitions //===----------------------------------------------------------------------===// namespace detail { ScalingTruncFOpGenericAdaptorBase::ScalingTruncFOpGenericAdaptorBase(ScalingTruncFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::arith::RoundingMode> ScalingTruncFOpGenericAdaptorBase::getRoundingmode() { auto attr = getRoundingmodeAttr(); return attr ? ::std::optional<::mlir::arith::RoundingMode>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::arith::FastMathFlags> ScalingTruncFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr ? ::std::optional<::mlir::arith::FastMathFlags>(attr.getValue()) : (::std::nullopt); } } // namespace detail ScalingTruncFOpAdaptor::ScalingTruncFOpAdaptor(ScalingTruncFOp op) : ScalingTruncFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ScalingTruncFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_roundingmode = getProperties().roundingmode; (void)tblgen_roundingmode; if (tblgen_roundingmode && !((::llvm::isa<::mlir::arith::RoundingModeAttr>(tblgen_roundingmode)))) return emitError(loc, "'arith.scaling_truncf' op attribute 'roundingmode' failed to satisfy constraint: Floating point rounding mode"); if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.scaling_truncf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); return ::mlir::success(); } ::llvm::LogicalResult ScalingTruncFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.roundingmode; auto attr = dict.get("roundingmode"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `roundingmode` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ScalingTruncFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } { const auto &propStorage = prop.roundingmode; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("roundingmode", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ScalingTruncFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer()), llvm::hash_value(prop.roundingmode.getAsOpaquePointer())); } std::optional ScalingTruncFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; if (name == "roundingmode") return prop.roundingmode; return std::nullopt; } void ScalingTruncFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } if (name == "roundingmode") { prop.roundingmode = ::llvm::dyn_cast_or_null>(value); return; } } void ScalingTruncFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); if (prop.roundingmode) attrs.append("roundingmode", prop.roundingmode); } ::llvm::LogicalResult ScalingTruncFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRoundingmodeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps2(attr, "roundingmode", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ScalingTruncFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.roundingmode))) return ::mlir::failure(); return ::mlir::success(); } void ScalingTruncFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); writer.writeOptionalAttribute(prop.roundingmode); } ::std::optional<::mlir::arith::RoundingMode> ScalingTruncFOp::getRoundingmode() { auto attr = getRoundingmodeAttr(); return attr ? ::std::optional<::mlir::arith::RoundingMode>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::arith::FastMathFlags> ScalingTruncFOp::getFastmath() { auto attr = getFastmathAttr(); return attr ? ::std::optional<::mlir::arith::FastMathFlags>(attr.getValue()) : (::std::nullopt); } void ScalingTruncFOp::setRoundingmode(::std::optional<::mlir::arith::RoundingMode> attrValue) { auto &odsProp = getProperties().roundingmode; if (attrValue) odsProp = ::mlir::arith::RoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void ScalingTruncFOp::setFastmath(::std::optional<::mlir::arith::FastMathFlags> attrValue) { auto &odsProp = getProperties().fastmath; if (attrValue) odsProp = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void ScalingTruncFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in, ::mlir::Value scale, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(in); odsState.addOperands(scale); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } odsState.addTypes(out); } ScalingTruncFOp ScalingTruncFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in, ::mlir::Value scale, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in), std::forward(scale), std::forward(roundingmode), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ScalingTruncFOp ScalingTruncFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in, ::mlir::Value scale, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in), std::forward(scale), std::forward(roundingmode), std::forward(fastmath)); } void ScalingTruncFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::Value scale, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(in); odsState.addOperands(scale); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ScalingTruncFOp ScalingTruncFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::Value scale, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in), std::forward(scale), std::forward(roundingmode), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ScalingTruncFOp ScalingTruncFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::Value scale, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in), std::forward(scale), std::forward(roundingmode), std::forward(fastmath)); } void ScalingTruncFOp::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."); } } ScalingTruncFOp ScalingTruncFOp::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__; } ScalingTruncFOp ScalingTruncFOp::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 ScalingTruncFOp::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); } ScalingTruncFOp ScalingTruncFOp::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__; } ScalingTruncFOp ScalingTruncFOp::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 ScalingTruncFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_roundingmode = getProperties().roundingmode; (void)tblgen_roundingmode; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps2(*this, tblgen_roundingmode, "roundingmode"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) && ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{}))))) return emitOpError("failed to verify that input and output have the same tensor dimensions"); return ::mlir::success(); } ::llvm::LogicalResult ScalingTruncFOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ScalingTruncFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand inRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inOperands(&inRawOperand, 1); ::llvm::SMLoc inOperandsLoc; (void)inOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand scaleRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> scaleOperands(&scaleRawOperand, 1); ::llvm::SMLoc scaleOperandsLoc; (void)scaleOperandsLoc; ::mlir::arith::RoundingModeAttr roundingmodeAttr; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type inRawType{}; ::llvm::ArrayRef<::mlir::Type> inTypes(&inRawType, 1); ::mlir::Type scaleRawType{}; ::llvm::ArrayRef<::mlir::Type> scaleTypes(&scaleRawType, 1); ::mlir::Type outRawType{}; ::llvm::ArrayRef<::mlir::Type> outTypes(&outRawType, 1); inOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); scaleOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(scaleRawOperand)) return ::mlir::failure(); { ::llvm::StringRef attrStr; ::mlir::NamedAttrList attrStorage; auto loc = parser.getCurrentLocation(); if (parser.parseOptionalKeyword(&attrStr, {"to_nearest_even","downward","upward","toward_zero","to_nearest_away"})) { ::mlir::StringAttr attrVal; ::mlir::OptionalParseResult parseResult = parser.parseOptionalAttribute(attrVal, parser.getBuilder().getNoneType(), "roundingmode", attrStorage); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); attrStr = attrVal.getValue(); } else { } } if (!attrStr.empty()) { auto attrOptional = ::mlir::arith::symbolizeRoundingMode(attrStr); if (!attrOptional) return parser.emitError(loc, "invalid ") << "roundingmode attribute specification: \"" << attrStr << '"';; roundingmodeAttr = ::mlir::arith::RoundingModeAttr::get(parser.getBuilder().getContext(), *attrOptional); result.getOrAddProperties().roundingmode = roundingmodeAttr; } } if (roundingmodeAttr) { } if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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(); inRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); scaleRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); outRawType = type; } result.addTypes(outTypes); if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(scaleOperands, scaleTypes, scaleOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ScalingTruncFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getIn(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getScale(); if (getRoundingmodeAttr()) { _odsPrinter << ' '; { auto caseValue = *getRoundingmode(); auto caseValueStr = stringifyRoundingMode(caseValue); _odsPrinter << caseValueStr; } } if (getFastmathAttr()) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("roundingmode"); elidedAttrs.push_back("fastmath"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getIn().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getScale().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getOut().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void ScalingTruncFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::ScalingTruncFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::ScalingTruncFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::ShLIOp definitions //===----------------------------------------------------------------------===// namespace detail { ShLIOpGenericAdaptorBase::ShLIOpGenericAdaptorBase(ShLIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::IntegerOverflowFlagsAttr ShLIOpGenericAdaptorBase::getOverflowFlagsAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::IntegerOverflowFlagsAttr>(getProperties().overflowFlags); return attr; } ::mlir::arith::IntegerOverflowFlags ShLIOpGenericAdaptorBase::getOverflowFlags() { auto attr = getOverflowFlagsAttr(); return attr.getValue(); } } // namespace detail ShLIOpAdaptor::ShLIOpAdaptor(ShLIOp op) : ShLIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ShLIOpAdaptor::verify(::mlir::Location loc) { auto tblgen_overflowFlags = getProperties().overflowFlags; (void)tblgen_overflowFlags; if (tblgen_overflowFlags && !((::llvm::isa<::mlir::arith::IntegerOverflowFlagsAttr>(tblgen_overflowFlags)))) return emitError(loc, "'arith.shli' op attribute 'overflowFlags' failed to satisfy constraint: Integer overflow arith flags"); return ::mlir::success(); } ::llvm::LogicalResult ShLIOp::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.overflowFlags; auto attr = dict.get("overflowFlags"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `overflowFlags` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ShLIOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.overflowFlags; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("overflowFlags", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ShLIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.overflowFlags.getAsOpaquePointer())); } std::optional ShLIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "overflowFlags") return prop.overflowFlags; return std::nullopt; } void ShLIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "overflowFlags") { prop.overflowFlags = ::llvm::dyn_cast_or_null>(value); return; } } void ShLIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.overflowFlags) attrs.append("overflowFlags", prop.overflowFlags); } ::llvm::LogicalResult ShLIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getOverflowFlagsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps3(attr, "overflowFlags", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ShLIOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.overflowFlags))) return ::mlir::failure(); return ::mlir::success(); } void ShLIOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.overflowFlags); } ::mlir::arith::IntegerOverflowFlags ShLIOp::getOverflowFlags() { auto attr = getOverflowFlagsAttr(); return attr.getValue(); } void ShLIOp::setOverflowFlags(::mlir::arith::IntegerOverflowFlags attrValue) { getProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ShLIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (overflowFlags) { odsState.getOrAddProperties().overflowFlags = overflowFlags; } odsState.addTypes(result); } ShLIOp ShLIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShLIOp ShLIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void ShLIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (overflowFlags) { odsState.getOrAddProperties().overflowFlags = overflowFlags; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ShLIOp::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); } ShLIOp ShLIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShLIOp ShLIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void ShLIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (overflowFlags) { odsState.getOrAddProperties().overflowFlags = overflowFlags; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ShLIOp ShLIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShLIOp ShLIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void ShLIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), overflowFlags); odsState.addTypes(result); } ShLIOp ShLIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShLIOp ShLIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void ShLIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), overflowFlags); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ShLIOp::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); } ShLIOp ShLIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShLIOp ShLIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void ShLIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), overflowFlags); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ShLIOp ShLIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShLIOp ShLIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void ShLIOp::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."); } } ShLIOp ShLIOp::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__; } ShLIOp ShLIOp::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 ShLIOp::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(ShLIOp::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)."); } } ShLIOp ShLIOp::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__; } ShLIOp ShLIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ShLIOp::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); } ShLIOp ShLIOp::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__; } ShLIOp ShLIOp::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 ShLIOp::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(ShLIOp::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)."); } } ShLIOp ShLIOp::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__; } ShLIOp ShLIOp::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)); } void ShLIOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.overflowFlags) properties.overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::IntegerOverflowFlags::none); } ::llvm::LogicalResult ShLIOp::verifyInvariantsImpl() { auto tblgen_overflowFlags = getProperties().overflowFlags; (void)tblgen_overflowFlags; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps3(*this, tblgen_overflowFlags, "overflowFlags"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ShLIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult ShLIOp::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 ShLIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::arith::IntegerOverflowFlagsAttr overflowFlagsAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("overflow"))) { if (parser.parseCustomAttributeWithFallback(overflowFlagsAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (overflowFlagsAttr) result.getOrAddProperties().overflowFlags = overflowFlagsAttr; } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ShLIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if (getOverflowFlagsAttr() != ::mlir::arith::IntegerOverflowFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::IntegerOverflowFlags::none)) { _odsPrinter << ' ' << "overflow"; _odsPrinter.printStrippedAttrOrType(getOverflowFlagsAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("overflowFlags"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getOverflowFlagsAttr(); if(attr && (attr == ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::IntegerOverflowFlags::none))) elidedAttrs.push_back("overflowFlags"); } _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 ShLIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::ShLIOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::ShLIOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::ShRSIOp definitions //===----------------------------------------------------------------------===// namespace detail { ShRSIOpGenericAdaptorBase::ShRSIOpGenericAdaptorBase(ShRSIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::UnitAttr ShRSIOpGenericAdaptorBase::getIsExactAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().isExact); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool ShRSIOpGenericAdaptorBase::getIsExact() { auto attr = getIsExactAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail ShRSIOpAdaptor::ShRSIOpAdaptor(ShRSIOp op) : ShRSIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ShRSIOpAdaptor::verify(::mlir::Location loc) { auto tblgen_isExact = getProperties().isExact; (void)tblgen_isExact; if (tblgen_isExact && !((::llvm::isa<::mlir::UnitAttr>(tblgen_isExact)))) return emitError(loc, "'arith.shrsi' op attribute 'isExact' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } ::llvm::LogicalResult ShRSIOp::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.isExact; auto attr = dict.get("isExact"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `isExact` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ShRSIOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.isExact; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("isExact", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ShRSIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.isExact.getAsOpaquePointer())); } std::optional ShRSIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "isExact") return prop.isExact; return std::nullopt; } void ShRSIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "isExact") { prop.isExact = ::llvm::dyn_cast_or_null>(value); return; } } void ShRSIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.isExact) attrs.append("isExact", prop.isExact); } ::llvm::LogicalResult ShRSIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getIsExactAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps7(attr, "isExact", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ShRSIOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.isExact))) return ::mlir::failure(); return ::mlir::success(); } void ShRSIOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.isExact); } bool ShRSIOp::getIsExact() { auto attr = getIsExactAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void ShRSIOp::setIsExact(bool attrValue) { auto &odsProp = getProperties().isExact; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void ShRSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = isExact; } odsState.addTypes(result); } ShRSIOp ShRSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShRSIOp ShRSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void ShRSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = isExact; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ShRSIOp::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); } ShRSIOp ShRSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShRSIOp ShRSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void ShRSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = isExact; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ShRSIOp ShRSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShRSIOp ShRSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void ShRSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = ((isExact) ? odsBuilder.getUnitAttr() : nullptr); } odsState.addTypes(result); } ShRSIOp ShRSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShRSIOp ShRSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void ShRSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = ((isExact) ? odsBuilder.getUnitAttr() : nullptr); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ShRSIOp::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); } ShRSIOp ShRSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShRSIOp ShRSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void ShRSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = ((isExact) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ShRSIOp ShRSIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShRSIOp ShRSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void ShRSIOp::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."); } } ShRSIOp ShRSIOp::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__; } ShRSIOp ShRSIOp::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 ShRSIOp::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(ShRSIOp::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)."); } } ShRSIOp ShRSIOp::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__; } ShRSIOp ShRSIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ShRSIOp::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); } ShRSIOp ShRSIOp::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__; } ShRSIOp ShRSIOp::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 ShRSIOp::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(ShRSIOp::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)."); } } ShRSIOp ShRSIOp::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__; } ShRSIOp ShRSIOp::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 ShRSIOp::verifyInvariantsImpl() { auto tblgen_isExact = getProperties().isExact; (void)tblgen_isExact; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps7(*this, tblgen_isExact, "isExact"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ShRSIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult ShRSIOp::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 ShRSIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("exact"))) { result.getOrAddProperties().isExact = parser.getBuilder().getUnitAttr(); } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ShRSIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if ((getIsExactAttr() && getIsExactAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "exact"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("isExact"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getIsExactAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("isExact"); } _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 ShRSIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::ShRSIOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::ShRSIOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::ShRUIOp definitions //===----------------------------------------------------------------------===// namespace detail { ShRUIOpGenericAdaptorBase::ShRUIOpGenericAdaptorBase(ShRUIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::UnitAttr ShRUIOpGenericAdaptorBase::getIsExactAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().isExact); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool ShRUIOpGenericAdaptorBase::getIsExact() { auto attr = getIsExactAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail ShRUIOpAdaptor::ShRUIOpAdaptor(ShRUIOp op) : ShRUIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ShRUIOpAdaptor::verify(::mlir::Location loc) { auto tblgen_isExact = getProperties().isExact; (void)tblgen_isExact; if (tblgen_isExact && !((::llvm::isa<::mlir::UnitAttr>(tblgen_isExact)))) return emitError(loc, "'arith.shrui' op attribute 'isExact' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } ::llvm::LogicalResult ShRUIOp::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.isExact; auto attr = dict.get("isExact"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `isExact` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ShRUIOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.isExact; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("isExact", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ShRUIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.isExact.getAsOpaquePointer())); } std::optional ShRUIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "isExact") return prop.isExact; return std::nullopt; } void ShRUIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "isExact") { prop.isExact = ::llvm::dyn_cast_or_null>(value); return; } } void ShRUIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.isExact) attrs.append("isExact", prop.isExact); } ::llvm::LogicalResult ShRUIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getIsExactAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps7(attr, "isExact", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ShRUIOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.isExact))) return ::mlir::failure(); return ::mlir::success(); } void ShRUIOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.isExact); } bool ShRUIOp::getIsExact() { auto attr = getIsExactAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void ShRUIOp::setIsExact(bool attrValue) { auto &odsProp = getProperties().isExact; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void ShRUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = isExact; } odsState.addTypes(result); } ShRUIOp ShRUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShRUIOp ShRUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void ShRUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = isExact; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ShRUIOp::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); } ShRUIOp ShRUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShRUIOp ShRUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void ShRUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = isExact; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ShRUIOp ShRUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShRUIOp ShRUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::UnitAttr isExact) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void ShRUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = ((isExact) ? odsBuilder.getUnitAttr() : nullptr); } odsState.addTypes(result); } ShRUIOp ShRUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShRUIOp ShRUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void ShRUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = ((isExact) ? odsBuilder.getUnitAttr() : nullptr); } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ShRUIOp::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); } ShRUIOp ShRUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShRUIOp ShRUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void ShRUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (isExact) { odsState.getOrAddProperties().isExact = ((isExact) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ShRUIOp ShRUIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShRUIOp ShRUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/bool isExact) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(isExact)); } void ShRUIOp::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."); } } ShRUIOp ShRUIOp::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__; } ShRUIOp ShRUIOp::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 ShRUIOp::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(ShRUIOp::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)."); } } ShRUIOp ShRUIOp::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__; } ShRUIOp ShRUIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ShRUIOp::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); } ShRUIOp ShRUIOp::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__; } ShRUIOp ShRUIOp::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 ShRUIOp::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(ShRUIOp::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)."); } } ShRUIOp ShRUIOp::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__; } ShRUIOp ShRUIOp::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 ShRUIOp::verifyInvariantsImpl() { auto tblgen_isExact = getProperties().isExact; (void)tblgen_isExact; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps7(*this, tblgen_isExact, "isExact"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ShRUIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult ShRUIOp::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 ShRUIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("exact"))) { result.getOrAddProperties().isExact = parser.getBuilder().getUnitAttr(); } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ShRUIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if ((getIsExactAttr() && getIsExactAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "exact"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("isExact"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getIsExactAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("isExact"); } _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 ShRUIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::ShRUIOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::ShRUIOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::SubFOp definitions //===----------------------------------------------------------------------===// namespace detail { SubFOpGenericAdaptorBase::SubFOpGenericAdaptorBase(SubFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::FastMathFlagsAttr SubFOpGenericAdaptorBase::getFastmathAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::FastMathFlagsAttr>(getProperties().fastmath); return attr; } ::mlir::arith::FastMathFlags SubFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } ::std::optional<::mlir::arith::RoundingMode> SubFOpGenericAdaptorBase::getRoundingmode() { auto attr = getRoundingmodeAttr(); return attr ? ::std::optional<::mlir::arith::RoundingMode>(attr.getValue()) : (::std::nullopt); } } // namespace detail SubFOpAdaptor::SubFOpAdaptor(SubFOp op) : SubFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SubFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_roundingmode = getProperties().roundingmode; (void)tblgen_roundingmode; if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.subf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); if (tblgen_roundingmode && !((::llvm::isa<::mlir::arith::RoundingModeAttr>(tblgen_roundingmode)))) return emitError(loc, "'arith.subf' op attribute 'roundingmode' failed to satisfy constraint: Floating point rounding mode"); return ::mlir::success(); } ::llvm::LogicalResult SubFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.roundingmode; auto attr = dict.get("roundingmode"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `roundingmode` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute SubFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } { const auto &propStorage = prop.roundingmode; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("roundingmode", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code SubFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer()), llvm::hash_value(prop.roundingmode.getAsOpaquePointer())); } std::optional SubFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; if (name == "roundingmode") return prop.roundingmode; return std::nullopt; } void SubFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } if (name == "roundingmode") { prop.roundingmode = ::llvm::dyn_cast_or_null>(value); return; } } void SubFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); if (prop.roundingmode) attrs.append("roundingmode", prop.roundingmode); } ::llvm::LogicalResult SubFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRoundingmodeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps2(attr, "roundingmode", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult SubFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.roundingmode))) return ::mlir::failure(); return ::mlir::success(); } void SubFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); writer.writeOptionalAttribute(prop.roundingmode); } ::mlir::arith::FastMathFlags SubFOp::getFastmath() { auto attr = getFastmathAttr(); return attr.getValue(); } ::std::optional<::mlir::arith::RoundingMode> SubFOp::getRoundingmode() { auto attr = getRoundingmodeAttr(); return attr ? ::std::optional<::mlir::arith::RoundingMode>(attr.getValue()) : (::std::nullopt); } void SubFOp::setFastmath(::mlir::arith::FastMathFlags attrValue) { getProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void SubFOp::setRoundingmode(::std::optional<::mlir::arith::RoundingMode> attrValue) { auto &odsProp = getProperties().roundingmode; if (attrValue) odsProp = ::mlir::arith::RoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { build(odsBuilder, odsState, lhs, rhs, fastmath, ::mlir::arith::RoundingModeAttr{}); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { build(odsBuilder, odsState, lhs, rhs, fastmath, ::mlir::arith::RoundingModeAttr{}); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value lhs, Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, Value lhs, Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type type, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { build(odsBuilder, odsState, type, lhs, rhs, ::mlir::arith::FastMathFlagsAttr::get( odsBuilder.getContext(), fastmath), ::mlir::arith::RoundingModeAttr{}); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type type, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(type), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, Type type, Value lhs, Value rhs, ::mlir::arith::FastMathFlags fastmath) { return create(builder, builder.getLoc(), std::forward(type), std::forward(lhs), std::forward(rhs), std::forward(fastmath)); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } odsState.addTypes(result); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SubFOp::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); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlagsAttr fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } odsState.addTypes(result); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SubFOp::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); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void SubFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SubFOp SubFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::FastMathFlags fastmath, /*optional*/::mlir::arith::RoundingModeAttr roundingmode) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(fastmath), std::forward(roundingmode)); } void SubFOp::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."); } } SubFOp SubFOp::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__; } SubFOp SubFOp::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 SubFOp::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(SubFOp::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)."); } } SubFOp SubFOp::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__; } SubFOp SubFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void SubFOp::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); } SubFOp SubFOp::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__; } SubFOp SubFOp::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 SubFOp::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(SubFOp::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)."); } } SubFOp SubFOp::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__; } SubFOp SubFOp::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)); } void SubFOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.fastmath) properties.fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none); } ::llvm::LogicalResult SubFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_roundingmode = getProperties().roundingmode; (void)tblgen_roundingmode; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps2(*this, tblgen_roundingmode, "roundingmode"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult SubFOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult SubFOp::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 SubFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::arith::RoundingModeAttr roundingmodeAttr; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); { ::llvm::StringRef attrStr; ::mlir::NamedAttrList attrStorage; auto loc = parser.getCurrentLocation(); if (parser.parseOptionalKeyword(&attrStr, {"to_nearest_even","downward","upward","toward_zero","to_nearest_away"})) { ::mlir::StringAttr attrVal; ::mlir::OptionalParseResult parseResult = parser.parseOptionalAttribute(attrVal, parser.getBuilder().getNoneType(), "roundingmode", attrStorage); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); attrStr = attrVal.getValue(); } else { } } if (!attrStr.empty()) { auto attrOptional = ::mlir::arith::symbolizeRoundingMode(attrStr); if (!attrOptional) return parser.emitError(loc, "invalid ") << "roundingmode attribute specification: \"" << attrStr << '"';; roundingmodeAttr = ::mlir::arith::RoundingModeAttr::get(parser.getBuilder().getContext(), *attrOptional); result.getOrAddProperties().roundingmode = roundingmodeAttr; } } if (roundingmodeAttr) { } if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void SubFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if (getRoundingmodeAttr()) { _odsPrinter << ' '; { auto caseValue = *getRoundingmode(); auto caseValueStr = stringifyRoundingMode(caseValue); _odsPrinter << caseValueStr; } } if (getFastmathAttr() != ::mlir::arith::FastMathFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::FastMathFlags::none)) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("roundingmode"); elidedAttrs.push_back("fastmath"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFastmathAttr(); if(attr && (attr == ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none))) elidedAttrs.push_back("fastmath"); } _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 SubFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::SubFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::SubFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::SubIOp definitions //===----------------------------------------------------------------------===// namespace detail { SubIOpGenericAdaptorBase::SubIOpGenericAdaptorBase(SubIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::IntegerOverflowFlagsAttr SubIOpGenericAdaptorBase::getOverflowFlagsAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::IntegerOverflowFlagsAttr>(getProperties().overflowFlags); return attr; } ::mlir::arith::IntegerOverflowFlags SubIOpGenericAdaptorBase::getOverflowFlags() { auto attr = getOverflowFlagsAttr(); return attr.getValue(); } } // namespace detail SubIOpAdaptor::SubIOpAdaptor(SubIOp op) : SubIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SubIOpAdaptor::verify(::mlir::Location loc) { auto tblgen_overflowFlags = getProperties().overflowFlags; (void)tblgen_overflowFlags; if (tblgen_overflowFlags && !((::llvm::isa<::mlir::arith::IntegerOverflowFlagsAttr>(tblgen_overflowFlags)))) return emitError(loc, "'arith.subi' op attribute 'overflowFlags' failed to satisfy constraint: Integer overflow arith flags"); return ::mlir::success(); } ::llvm::LogicalResult SubIOp::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.overflowFlags; auto attr = dict.get("overflowFlags"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `overflowFlags` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute SubIOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.overflowFlags; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("overflowFlags", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code SubIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.overflowFlags.getAsOpaquePointer())); } std::optional SubIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "overflowFlags") return prop.overflowFlags; return std::nullopt; } void SubIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "overflowFlags") { prop.overflowFlags = ::llvm::dyn_cast_or_null>(value); return; } } void SubIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.overflowFlags) attrs.append("overflowFlags", prop.overflowFlags); } ::llvm::LogicalResult SubIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getOverflowFlagsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps3(attr, "overflowFlags", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult SubIOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.overflowFlags))) return ::mlir::failure(); return ::mlir::success(); } void SubIOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.overflowFlags); } ::mlir::arith::IntegerOverflowFlags SubIOp::getOverflowFlags() { auto attr = getOverflowFlagsAttr(); return attr.getValue(); } void SubIOp::setOverflowFlags(::mlir::arith::IntegerOverflowFlags attrValue) { getProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void SubIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (overflowFlags) { odsState.getOrAddProperties().overflowFlags = overflowFlags; } odsState.addTypes(result); } SubIOp SubIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubIOp SubIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void SubIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (overflowFlags) { odsState.getOrAddProperties().overflowFlags = overflowFlags; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SubIOp::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); } SubIOp SubIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubIOp SubIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void SubIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); if (overflowFlags) { odsState.getOrAddProperties().overflowFlags = overflowFlags; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SubIOp SubIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubIOp SubIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void SubIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), overflowFlags); odsState.addTypes(result); } SubIOp SubIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubIOp SubIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void SubIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), overflowFlags); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SubIOp::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); } SubIOp SubIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubIOp SubIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void SubIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.getOrAddProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), overflowFlags); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SubIOp SubIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubIOp SubIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::arith::IntegerOverflowFlags overflowFlags) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs), std::forward(overflowFlags)); } void SubIOp::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."); } } SubIOp SubIOp::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__; } SubIOp SubIOp::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 SubIOp::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(SubIOp::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)."); } } SubIOp SubIOp::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__; } SubIOp SubIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void SubIOp::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); } SubIOp SubIOp::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__; } SubIOp SubIOp::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 SubIOp::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(SubIOp::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)."); } } SubIOp SubIOp::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__; } SubIOp SubIOp::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)); } void SubIOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.overflowFlags) properties.overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::IntegerOverflowFlags::none); } ::llvm::LogicalResult SubIOp::verifyInvariantsImpl() { auto tblgen_overflowFlags = getProperties().overflowFlags; (void)tblgen_overflowFlags; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps3(*this, tblgen_overflowFlags, "overflowFlags"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult SubIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult SubIOp::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 SubIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::arith::IntegerOverflowFlagsAttr overflowFlagsAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("overflow"))) { if (parser.parseCustomAttributeWithFallback(overflowFlagsAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (overflowFlagsAttr) result.getOrAddProperties().overflowFlags = overflowFlagsAttr; } { 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void SubIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); if (getOverflowFlagsAttr() != ::mlir::arith::IntegerOverflowFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::IntegerOverflowFlags::none)) { _odsPrinter << ' ' << "overflow"; _odsPrinter.printStrippedAttrOrType(getOverflowFlagsAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("overflowFlags"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getOverflowFlagsAttr(); if(attr && (attr == ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::IntegerOverflowFlags::none))) elidedAttrs.push_back("overflowFlags"); } _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 SubIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::SubIOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::SubIOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::SubUIExtendedOp definitions //===----------------------------------------------------------------------===// namespace detail { SubUIExtendedOpGenericAdaptorBase::SubUIExtendedOpGenericAdaptorBase(SubUIExtendedOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail SubUIExtendedOpAdaptor::SubUIExtendedOpAdaptor(SubUIExtendedOp op) : SubUIExtendedOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SubUIExtendedOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } void SubUIExtendedOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { auto resultGroup0 = getODSResults(0); if (!resultGroup0.empty()) setNameFn(*resultGroup0.begin(), "diff"); auto resultGroup1 = getODSResults(1); if (!resultGroup1.empty()) setNameFn(*resultGroup1.begin(), "borrow"); } ::llvm::LogicalResult SubUIExtendedOp::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 SubUIExtendedOp::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 SubUIExtendedOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional SubUIExtendedOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void SubUIExtendedOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void SubUIExtendedOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult SubUIExtendedOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void SubUIExtendedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs) { build(odsBuilder, odsState, lhs.getType(), ::getI1SameShape(lhs.getType()), lhs, rhs); } SubUIExtendedOp SubUIExtendedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value lhs, Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubUIExtendedOp SubUIExtendedOp::create(::mlir::ImplicitLocOpBuilder &builder, Value lhs, Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void SubUIExtendedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type diff, ::mlir::Type borrow, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(diff); odsState.addTypes(borrow); } SubUIExtendedOp SubUIExtendedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type diff, ::mlir::Type borrow, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(diff), std::forward(borrow), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubUIExtendedOp SubUIExtendedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type diff, ::mlir::Type borrow, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(diff), std::forward(borrow), std::forward(lhs), std::forward(rhs)); } void SubUIExtendedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 2u && "mismatched number of results"); odsState.addTypes(resultTypes); } SubUIExtendedOp SubUIExtendedOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SubUIExtendedOp SubUIExtendedOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void SubUIExtendedOp::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() == 2u && "mismatched number of return types"); odsState.addTypes(resultTypes); } SubUIExtendedOp SubUIExtendedOp::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__; } SubUIExtendedOp SubUIExtendedOp::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 SubUIExtendedOp::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() == 2u && "mismatched number of return types"); odsState.addTypes(resultTypes); } SubUIExtendedOp SubUIExtendedOp::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__; } SubUIExtendedOp SubUIExtendedOp::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 SubUIExtendedOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSResults(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps3(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType()) && ((*this->getODSOperands(1).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 {lhs, rhs, diff} have same type"); return ::mlir::success(); } ::llvm::LogicalResult SubUIExtendedOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult SubUIExtendedOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type diffRawType{}; ::llvm::ArrayRef<::mlir::Type> diffTypes(&diffRawType, 1); ::mlir::Type borrowRawType{}; ::llvm::ArrayRef<::mlir::Type> borrowTypes(&borrowRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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(); diffRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); borrowRawType = type; } result.addTypes(diffTypes); result.addTypes(borrowTypes); if (parser.resolveOperands(lhsOperands, diffTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, diffTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void SubUIExtendedOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getDiff().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getBorrow().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void SubUIExtendedOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::SubUIExtendedOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::TruncFOp definitions //===----------------------------------------------------------------------===// namespace detail { TruncFOpGenericAdaptorBase::TruncFOpGenericAdaptorBase(TruncFOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional<::mlir::arith::RoundingMode> TruncFOpGenericAdaptorBase::getRoundingmode() { auto attr = getRoundingmodeAttr(); return attr ? ::std::optional<::mlir::arith::RoundingMode>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::arith::FastMathFlags> TruncFOpGenericAdaptorBase::getFastmath() { auto attr = getFastmathAttr(); return attr ? ::std::optional<::mlir::arith::FastMathFlags>(attr.getValue()) : (::std::nullopt); } } // namespace detail TruncFOpAdaptor::TruncFOpAdaptor(TruncFOp op) : TruncFOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult TruncFOpAdaptor::verify(::mlir::Location loc) { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_roundingmode = getProperties().roundingmode; (void)tblgen_roundingmode; if (tblgen_roundingmode && !((::llvm::isa<::mlir::arith::RoundingModeAttr>(tblgen_roundingmode)))) return emitError(loc, "'arith.truncf' op attribute 'roundingmode' failed to satisfy constraint: Floating point rounding mode"); if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) return emitError(loc, "'arith.truncf' op attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); return ::mlir::success(); } ::llvm::LogicalResult TruncFOp::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.fastmath; auto attr = dict.get("fastmath"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.roundingmode; auto attr = dict.get("roundingmode"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `roundingmode` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute TruncFOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.fastmath; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("fastmath", propStorage)); } { const auto &propStorage = prop.roundingmode; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("roundingmode", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code TruncFOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.fastmath.getAsOpaquePointer()), llvm::hash_value(prop.roundingmode.getAsOpaquePointer())); } std::optional TruncFOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "fastmath") return prop.fastmath; if (name == "roundingmode") return prop.roundingmode; return std::nullopt; } void TruncFOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "fastmath") { prop.fastmath = ::llvm::dyn_cast_or_null>(value); return; } if (name == "roundingmode") { prop.roundingmode = ::llvm::dyn_cast_or_null>(value); return; } } void TruncFOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.fastmath) attrs.append("fastmath", prop.fastmath); if (prop.roundingmode) attrs.append("roundingmode", prop.roundingmode); } ::llvm::LogicalResult TruncFOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(attr, "fastmath", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRoundingmodeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps2(attr, "roundingmode", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult TruncFOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.roundingmode))) return ::mlir::failure(); return ::mlir::success(); } void TruncFOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.fastmath); writer.writeOptionalAttribute(prop.roundingmode); } ::std::optional<::mlir::arith::RoundingMode> TruncFOp::getRoundingmode() { auto attr = getRoundingmodeAttr(); return attr ? ::std::optional<::mlir::arith::RoundingMode>(attr.getValue()) : (::std::nullopt); } ::std::optional<::mlir::arith::FastMathFlags> TruncFOp::getFastmath() { auto attr = getFastmathAttr(); return attr ? ::std::optional<::mlir::arith::FastMathFlags>(attr.getValue()) : (::std::nullopt); } void TruncFOp::setRoundingmode(::std::optional<::mlir::arith::RoundingMode> attrValue) { auto &odsProp = getProperties().roundingmode; if (attrValue) odsProp = ::mlir::arith::RoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void TruncFOp::setFastmath(::std::optional<::mlir::arith::FastMathFlags> attrValue) { auto &odsProp = getProperties().fastmath; if (attrValue) odsProp = ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void TruncFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type out, Value in) { odsState.addOperands(in); odsState.addTypes(out); } TruncFOp TruncFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type out, Value in) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TruncFOp TruncFOp::create(::mlir::ImplicitLocOpBuilder &builder, Type out, Value in) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in)); } void TruncFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(in); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } odsState.addTypes(out); } TruncFOp TruncFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in), std::forward(roundingmode), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TruncFOp TruncFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in), std::forward(roundingmode), std::forward(fastmath)); } void TruncFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { odsState.addOperands(in); if (roundingmode) { odsState.getOrAddProperties().roundingmode = roundingmode; } if (fastmath) { odsState.getOrAddProperties().fastmath = fastmath; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } TruncFOp TruncFOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in), std::forward(roundingmode), std::forward(fastmath)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TruncFOp TruncFOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::arith::RoundingModeAttr roundingmode, /*optional*/::mlir::arith::FastMathFlagsAttr fastmath) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in), std::forward(roundingmode), std::forward(fastmath)); } void TruncFOp::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."); } } TruncFOp TruncFOp::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__; } TruncFOp TruncFOp::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 TruncFOp::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); } TruncFOp TruncFOp::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__; } TruncFOp TruncFOp::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 TruncFOp::verifyInvariantsImpl() { auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; auto tblgen_roundingmode = getProperties().roundingmode; (void)tblgen_roundingmode; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps2(*this, tblgen_roundingmode, "roundingmode"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps1(*this, tblgen_fastmath, "fastmath"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps1(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) && ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{}))))) return emitOpError("failed to verify that input and output have the same tensor dimensions"); return ::mlir::success(); } ::llvm::LogicalResult TruncFOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult TruncFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand inRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inOperands(&inRawOperand, 1); ::llvm::SMLoc inOperandsLoc; (void)inOperandsLoc; ::mlir::arith::RoundingModeAttr roundingmodeAttr; ::mlir::arith::FastMathFlagsAttr fastmathAttr; ::mlir::Type inRawType{}; ::llvm::ArrayRef<::mlir::Type> inTypes(&inRawType, 1); ::mlir::Type outRawType{}; ::llvm::ArrayRef<::mlir::Type> outTypes(&outRawType, 1); inOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inRawOperand)) return ::mlir::failure(); { ::llvm::StringRef attrStr; ::mlir::NamedAttrList attrStorage; auto loc = parser.getCurrentLocation(); if (parser.parseOptionalKeyword(&attrStr, {"to_nearest_even","downward","upward","toward_zero","to_nearest_away"})) { ::mlir::StringAttr attrVal; ::mlir::OptionalParseResult parseResult = parser.parseOptionalAttribute(attrVal, parser.getBuilder().getNoneType(), "roundingmode", attrStorage); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); attrStr = attrVal.getValue(); } else { } } if (!attrStr.empty()) { auto attrOptional = ::mlir::arith::symbolizeRoundingMode(attrStr); if (!attrOptional) return parser.emitError(loc, "invalid ") << "roundingmode attribute specification: \"" << attrStr << '"';; roundingmodeAttr = ::mlir::arith::RoundingModeAttr::get(parser.getBuilder().getContext(), *attrOptional); result.getOrAddProperties().roundingmode = roundingmodeAttr; } } if (roundingmodeAttr) { } if (::mlir::succeeded(parser.parseOptionalKeyword("fastmath"))) { if (parser.parseCustomAttributeWithFallback(fastmathAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (fastmathAttr) result.getOrAddProperties().fastmath = fastmathAttr; } { 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(); inRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); outRawType = type; } result.addTypes(outTypes); if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void TruncFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getIn(); if (getRoundingmodeAttr()) { _odsPrinter << ' '; { auto caseValue = *getRoundingmode(); auto caseValueStr = stringifyRoundingMode(caseValue); _odsPrinter << caseValueStr; } } if (getFastmathAttr()) { _odsPrinter << ' ' << "fastmath"; _odsPrinter.printStrippedAttrOrType(getFastmathAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("roundingmode"); elidedAttrs.push_back("fastmath"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getIn().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getOut().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void TruncFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::TruncFOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::TruncFOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::TruncIOp definitions //===----------------------------------------------------------------------===// namespace detail { TruncIOpGenericAdaptorBase::TruncIOpGenericAdaptorBase(TruncIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::arith::IntegerOverflowFlagsAttr TruncIOpGenericAdaptorBase::getOverflowFlagsAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::IntegerOverflowFlagsAttr>(getProperties().overflowFlags); return attr; } ::mlir::arith::IntegerOverflowFlags TruncIOpGenericAdaptorBase::getOverflowFlags() { auto attr = getOverflowFlagsAttr(); return attr.getValue(); } } // namespace detail TruncIOpAdaptor::TruncIOpAdaptor(TruncIOp op) : TruncIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult TruncIOpAdaptor::verify(::mlir::Location loc) { auto tblgen_overflowFlags = getProperties().overflowFlags; (void)tblgen_overflowFlags; if (tblgen_overflowFlags && !((::llvm::isa<::mlir::arith::IntegerOverflowFlagsAttr>(tblgen_overflowFlags)))) return emitError(loc, "'arith.trunci' op attribute 'overflowFlags' failed to satisfy constraint: Integer overflow arith flags"); return ::mlir::success(); } ::llvm::LogicalResult TruncIOp::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.overflowFlags; auto attr = dict.get("overflowFlags"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `overflowFlags` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute TruncIOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.overflowFlags; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("overflowFlags", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code TruncIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.overflowFlags.getAsOpaquePointer())); } std::optional TruncIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "overflowFlags") return prop.overflowFlags; return std::nullopt; } void TruncIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "overflowFlags") { prop.overflowFlags = ::llvm::dyn_cast_or_null>(value); return; } } void TruncIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.overflowFlags) attrs.append("overflowFlags", prop.overflowFlags); } ::llvm::LogicalResult TruncIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getOverflowFlagsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps3(attr, "overflowFlags", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult TruncIOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.overflowFlags))) return ::mlir::failure(); return ::mlir::success(); } void TruncIOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.overflowFlags); } ::mlir::arith::IntegerOverflowFlags TruncIOp::getOverflowFlags() { auto attr = getOverflowFlagsAttr(); return attr.getValue(); } void TruncIOp::setOverflowFlags(::mlir::arith::IntegerOverflowFlags attrValue) { getProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void TruncIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { odsState.addOperands(in); if (overflowFlags) { odsState.getOrAddProperties().overflowFlags = overflowFlags; } odsState.addTypes(out); } TruncIOp TruncIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TruncIOp TruncIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in), std::forward(overflowFlags)); } void TruncIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { odsState.addOperands(in); if (overflowFlags) { odsState.getOrAddProperties().overflowFlags = overflowFlags; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } TruncIOp TruncIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TruncIOp TruncIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::arith::IntegerOverflowFlagsAttr overflowFlags) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in), std::forward(overflowFlags)); } void TruncIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in, ::mlir::arith::IntegerOverflowFlags overflowFlags) { odsState.addOperands(in); odsState.getOrAddProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), overflowFlags); odsState.addTypes(out); } TruncIOp TruncIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in, ::mlir::arith::IntegerOverflowFlags overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TruncIOp TruncIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in, ::mlir::arith::IntegerOverflowFlags overflowFlags) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in), std::forward(overflowFlags)); } void TruncIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::arith::IntegerOverflowFlags overflowFlags) { odsState.addOperands(in); odsState.getOrAddProperties().overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), overflowFlags); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } TruncIOp TruncIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::arith::IntegerOverflowFlags overflowFlags) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in), std::forward(overflowFlags)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TruncIOp TruncIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in, ::mlir::arith::IntegerOverflowFlags overflowFlags) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in), std::forward(overflowFlags)); } void TruncIOp::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."); } } TruncIOp TruncIOp::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__; } TruncIOp TruncIOp::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 TruncIOp::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); } TruncIOp TruncIOp::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__; } TruncIOp TruncIOp::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 TruncIOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.overflowFlags) properties.overflowFlags = ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::IntegerOverflowFlags::none); } ::llvm::LogicalResult TruncIOp::verifyInvariantsImpl() { auto tblgen_overflowFlags = getProperties().overflowFlags; (void)tblgen_overflowFlags; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps3(*this, tblgen_overflowFlags, "overflowFlags"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps6(*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_ArithOps6(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) && ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{}))))) return emitOpError("failed to verify that input and output have the same tensor dimensions"); return ::mlir::success(); } ::llvm::LogicalResult TruncIOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult TruncIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand inRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inOperands(&inRawOperand, 1); ::llvm::SMLoc inOperandsLoc; (void)inOperandsLoc; ::mlir::arith::IntegerOverflowFlagsAttr overflowFlagsAttr; ::mlir::Type inRawType{}; ::llvm::ArrayRef<::mlir::Type> inTypes(&inRawType, 1); ::mlir::Type outRawType{}; ::llvm::ArrayRef<::mlir::Type> outTypes(&outRawType, 1); inOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("overflow"))) { if (parser.parseCustomAttributeWithFallback(overflowFlagsAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (overflowFlagsAttr) result.getOrAddProperties().overflowFlags = overflowFlagsAttr; } { 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(); inRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); outRawType = type; } result.addTypes(outTypes); if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void TruncIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getIn(); if (getOverflowFlagsAttr() != ::mlir::arith::IntegerOverflowFlagsAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::arith::IntegerOverflowFlags::none)) { _odsPrinter << ' ' << "overflow"; _odsPrinter.printStrippedAttrOrType(getOverflowFlagsAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("overflowFlags"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getOverflowFlagsAttr(); if(attr && (attr == ::mlir::arith::IntegerOverflowFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::IntegerOverflowFlags::none))) elidedAttrs.push_back("overflowFlags"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getIn().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getOut().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void TruncIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::TruncIOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::TruncIOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::UIToFPOp definitions //===----------------------------------------------------------------------===// namespace detail { UIToFPOpGenericAdaptorBase::UIToFPOpGenericAdaptorBase(UIToFPOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::UnitAttr UIToFPOpGenericAdaptorBase::getNonNegAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nonNeg); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool UIToFPOpGenericAdaptorBase::getNonNeg() { auto attr = getNonNegAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail UIToFPOpAdaptor::UIToFPOpAdaptor(UIToFPOp op) : UIToFPOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult UIToFPOpAdaptor::verify(::mlir::Location loc) { auto tblgen_nonNeg = getProperties().nonNeg; (void)tblgen_nonNeg; if (tblgen_nonNeg && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nonNeg)))) return emitError(loc, "'arith.uitofp' op attribute 'nonNeg' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } ::llvm::LogicalResult UIToFPOp::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.nonNeg; auto attr = dict.get("nonNeg"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `nonNeg` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute UIToFPOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.nonNeg; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("nonNeg", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code UIToFPOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.nonNeg.getAsOpaquePointer())); } std::optional UIToFPOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "nonNeg") return prop.nonNeg; return std::nullopt; } void UIToFPOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "nonNeg") { prop.nonNeg = ::llvm::dyn_cast_or_null>(value); return; } } void UIToFPOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.nonNeg) attrs.append("nonNeg", prop.nonNeg); } ::llvm::LogicalResult UIToFPOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getNonNegAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps7(attr, "nonNeg", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult UIToFPOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.nonNeg))) return ::mlir::failure(); return ::mlir::success(); } void UIToFPOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.nonNeg); } bool UIToFPOp::getNonNeg() { auto attr = getNonNegAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void UIToFPOp::setNonNeg(bool attrValue) { auto &odsProp = getProperties().nonNeg; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void UIToFPOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { odsState.addOperands(in); if (nonNeg) { odsState.getOrAddProperties().nonNeg = nonNeg; } odsState.addTypes(out); } UIToFPOp UIToFPOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in), std::forward(nonNeg)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UIToFPOp UIToFPOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in), std::forward(nonNeg)); } void UIToFPOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { odsState.addOperands(in); if (nonNeg) { odsState.getOrAddProperties().nonNeg = nonNeg; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } UIToFPOp UIToFPOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in), std::forward(nonNeg)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UIToFPOp UIToFPOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/::mlir::UnitAttr nonNeg) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in), std::forward(nonNeg)); } void UIToFPOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in, /*optional*/bool nonNeg) { odsState.addOperands(in); if (nonNeg) { odsState.getOrAddProperties().nonNeg = ((nonNeg) ? odsBuilder.getUnitAttr() : nullptr); } odsState.addTypes(out); } UIToFPOp UIToFPOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type out, ::mlir::Value in, /*optional*/bool nonNeg) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(out), std::forward(in), std::forward(nonNeg)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UIToFPOp UIToFPOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type out, ::mlir::Value in, /*optional*/bool nonNeg) { return create(builder, builder.getLoc(), std::forward(out), std::forward(in), std::forward(nonNeg)); } void UIToFPOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/bool nonNeg) { odsState.addOperands(in); if (nonNeg) { odsState.getOrAddProperties().nonNeg = ((nonNeg) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } UIToFPOp UIToFPOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/bool nonNeg) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(in), std::forward(nonNeg)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UIToFPOp UIToFPOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value in, /*optional*/bool nonNeg) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(in), std::forward(nonNeg)); } void UIToFPOp::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."); } } UIToFPOp UIToFPOp::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__; } UIToFPOp UIToFPOp::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 UIToFPOp::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); } UIToFPOp UIToFPOp::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__; } UIToFPOp UIToFPOp::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 UIToFPOp::verifyInvariantsImpl() { auto tblgen_nonNeg = getProperties().nonNeg; (void)tblgen_nonNeg; if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithOps7(*this, tblgen_nonNeg, "nonNeg"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps6(*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_ArithOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) && ((::llvm::isa<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSResults(0).begin()).getType()).getShape() : ::llvm::ArrayRef{})) == ((::llvm::isa<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()) ? ::llvm::cast<::mlir::TensorType>((*this->getODSOperands(0).begin()).getType()).getShape() : ::llvm::ArrayRef{}))))) return emitOpError("failed to verify that input and output have the same tensor dimensions"); return ::mlir::success(); } ::llvm::LogicalResult UIToFPOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult UIToFPOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand inRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inOperands(&inRawOperand, 1); ::llvm::SMLoc inOperandsLoc; (void)inOperandsLoc; ::mlir::Type inRawType{}; ::llvm::ArrayRef<::mlir::Type> inTypes(&inRawType, 1); ::mlir::Type outRawType{}; ::llvm::ArrayRef<::mlir::Type> outTypes(&outRawType, 1); inOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(inRawOperand)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("nneg"))) { result.getOrAddProperties().nonNeg = parser.getBuilder().getUnitAttr(); } { 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(); inRawType = type; } if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); outRawType = type; } result.addTypes(outTypes); if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void UIToFPOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getIn(); if ((getNonNegAttr() && getNonNegAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "nneg"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("nonNeg"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getNonNegAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("nonNeg"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getIn().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getOut().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void UIToFPOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::UIToFPOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::detail::UIToFPOpGenericAdaptorBase::Properties) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::XOrIOp definitions //===----------------------------------------------------------------------===// namespace detail { XOrIOpGenericAdaptorBase::XOrIOpGenericAdaptorBase(XOrIOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail XOrIOpAdaptor::XOrIOpAdaptor(XOrIOp op) : XOrIOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult XOrIOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult XOrIOp::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 XOrIOp::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 XOrIOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional XOrIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void XOrIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void XOrIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult XOrIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void XOrIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); odsState.addTypes(result); } XOrIOp XOrIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } XOrIOp XOrIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lhs), std::forward(rhs)); } void XOrIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(XOrIOp::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); } XOrIOp XOrIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } XOrIOp XOrIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(lhs), std::forward(rhs)); } void XOrIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { odsState.addOperands(lhs); odsState.addOperands(rhs); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } XOrIOp XOrIOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } XOrIOp XOrIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lhs), std::forward(rhs)); } void XOrIOp::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); } XOrIOp XOrIOp::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__; } XOrIOp XOrIOp::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 XOrIOp::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(XOrIOp::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)."); } } XOrIOp XOrIOp::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__; } XOrIOp XOrIOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void XOrIOp::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); } XOrIOp XOrIOp::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__; } XOrIOp XOrIOp::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 XOrIOp::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(XOrIOp::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)."); } } XOrIOp XOrIOp::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__; } XOrIOp XOrIOp::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 XOrIOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps2(*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_ArithOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult XOrIOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult XOrIOp::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 XOrIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; (void)lhsOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; (void)rhsOperandsLoc; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); lhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(lhsRawOperand)) return ::mlir::failure(); if (parser.parseComma()) return ::mlir::failure(); rhsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(rhsRawOperand)) 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; } result.addTypes(resultTypes); if (parser.resolveOperands(lhsOperands, resultTypes[0], lhsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(rhsOperands, resultTypes[0], rhsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void XOrIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getLhs(); _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter << getRhs(); ::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 XOrIOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::XOrIOp) namespace mlir::arith { //===----------------------------------------------------------------------===// // ::mlir::arith::SelectOp definitions //===----------------------------------------------------------------------===// namespace detail { SelectOpGenericAdaptorBase::SelectOpGenericAdaptorBase(SelectOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail SelectOpAdaptor::SelectOpAdaptor(SelectOp op) : SelectOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SelectOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult SelectOp::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 SelectOp::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 SelectOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional SelectOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void SelectOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void SelectOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult SelectOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value condition, ::mlir::Value true_value, ::mlir::Value false_value) { odsState.addOperands(condition); odsState.addOperands(true_value); odsState.addOperands(false_value); odsState.addTypes(result); } SelectOp SelectOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value condition, ::mlir::Value true_value, ::mlir::Value false_value) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(condition), std::forward(true_value), std::forward(false_value)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SelectOp SelectOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value condition, ::mlir::Value true_value, ::mlir::Value false_value) { return create(builder, builder.getLoc(), std::forward(result), std::forward(condition), std::forward(true_value), std::forward(false_value)); } void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value condition, ::mlir::Value true_value, ::mlir::Value false_value) { odsState.addOperands(condition); odsState.addOperands(true_value); odsState.addOperands(false_value); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SelectOp::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); } SelectOp SelectOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value condition, ::mlir::Value true_value, ::mlir::Value false_value) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(condition), std::forward(true_value), std::forward(false_value)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SelectOp SelectOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value condition, ::mlir::Value true_value, ::mlir::Value false_value) { return create(builder, builder.getLoc(), std::forward(condition), std::forward(true_value), std::forward(false_value)); } void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value condition, ::mlir::Value true_value, ::mlir::Value false_value) { odsState.addOperands(condition); odsState.addOperands(true_value); odsState.addOperands(false_value); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } SelectOp SelectOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value condition, ::mlir::Value true_value, ::mlir::Value false_value) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(condition), std::forward(true_value), std::forward(false_value)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SelectOp SelectOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value condition, ::mlir::Value true_value, ::mlir::Value false_value) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(condition), std::forward(true_value), std::forward(false_value)); } void SelectOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } SelectOp SelectOp::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__; } SelectOp SelectOp::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 SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SelectOp::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)."); } } SelectOp SelectOp::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__; } SelectOp SelectOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void SelectOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 3u && "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); } SelectOp SelectOp::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__; } SelectOp SelectOp::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 SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 3u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(SelectOp::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)."); } } SelectOp SelectOp::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__; } SelectOp SelectOp::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 SelectOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps3(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_ArithOps5(*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_ArithOps5(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } if (!((((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSOperands(2).begin()).getType()) && ((*this->getODSOperands(2).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType())))) return emitOpError("failed to verify that all of {true_value, false_value, result} have same type"); if (!((((*this->getODSOperands(0).begin()).getType().isSignlessInteger(1))) || (((::llvm::isa<::mlir::ShapedType>((*this->getODSOperands(0).begin()).getType()))) && ((::llvm::isa<::mlir::ShapedType>((*this->getODSResults(0).begin()).getType()))) && (((::llvm::cast<::mlir::ShapedType>((*this->getODSOperands(0).begin()).getType()).getShape()) == (::llvm::cast<::mlir::ShapedType>((*this->getODSResults(0).begin()).getType()).getShape()) && (::llvm::cast<::mlir::ShapedType>((*this->getODSResults(0).begin()).getType()).getShape()) == (::llvm::cast<::mlir::ShapedType>((*this->getODSOperands(0).begin()).getType()).getShape())))))) return emitOpError("failed to verify that condition is signless i1 or has matching shape"); return ::mlir::success(); } ::llvm::LogicalResult SelectOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult SelectOp::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() <= 2) return ::mlir::failure(); ::mlir::Type odsInferredType0 = operands[2].getType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::llvm::LogicalResult SelectOp::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 SelectOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::arith MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::SelectOp) #endif // GET_OP_CLASSES