/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |* *| |* Op Definitions *| |* *| |* Automatically generated file, do not edit! *| |* From: BuiltinOps.td *| |* *| \*===----------------------------------------------------------------------===*/ #ifdef GET_OP_LIST #undef GET_OP_LIST ::mlir::ModuleOp, ::mlir::UnrealizedConversionCastOp #endif // GET_OP_LIST #ifdef GET_OP_CLASSES #undef GET_OP_CLASSES //===----------------------------------------------------------------------===// // Local Utility Method Definitions //===----------------------------------------------------------------------===// static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BuiltinOps1( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(!((::llvm::isa<::mlir::TokenType>(type))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be variadic of any non-token type, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_BuiltinOps1( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::StringAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: string attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_BuiltinOps1( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_BuiltinOps1(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_region_constraint_BuiltinOps1( ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, unsigned regionIndex) { if (!((::llvm::hasNItems(region, 1)))) { return op->emitOpError("region #") << regionIndex << (regionName.empty() ? " " : " ('" + regionName + "') ") << "failed to verify constraint: region with 1 blocks"; } return ::mlir::success(); } namespace mlir { //===----------------------------------------------------------------------===// // ::mlir::ModuleOp definitions //===----------------------------------------------------------------------===// namespace detail { ModuleOpGenericAdaptorBase::ModuleOpGenericAdaptorBase(ModuleOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::std::optional< ::llvm::StringRef > ModuleOpGenericAdaptorBase::getSymName() { auto attr = getSymNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::llvm::StringRef > ModuleOpGenericAdaptorBase::getSymVisibility() { auto attr = getSymVisibilityAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } } // namespace detail ModuleOpAdaptor::ModuleOpAdaptor(ModuleOp op) : ModuleOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ModuleOpAdaptor::verify(::mlir::Location loc) { auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; auto tblgen_sym_visibility = getProperties().sym_visibility; (void)tblgen_sym_visibility; if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name)))) return emitError(loc, "'builtin.module' op attribute 'sym_name' failed to satisfy constraint: string attribute"); if (tblgen_sym_visibility && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_visibility)))) return emitError(loc, "'builtin.module' op attribute 'sym_visibility' failed to satisfy constraint: string attribute"); return ::mlir::success(); } ::llvm::LogicalResult ModuleOp::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.sym_name; auto attr = dict.get("sym_name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sym_name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sym_visibility; auto attr = dict.get("sym_visibility"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sym_visibility` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ModuleOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.sym_name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sym_name", propStorage)); } { const auto &propStorage = prop.sym_visibility; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sym_visibility", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ModuleOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.sym_name.getAsOpaquePointer()), llvm::hash_value(prop.sym_visibility.getAsOpaquePointer())); } std::optional ModuleOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "sym_name") return prop.sym_name; if (name == "sym_visibility") return prop.sym_visibility; return std::nullopt; } void ModuleOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "sym_name") { prop.sym_name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sym_visibility") { prop.sym_visibility = ::llvm::dyn_cast_or_null>(value); return; } } void ModuleOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.sym_name) attrs.append("sym_name", prop.sym_name); if (prop.sym_visibility) attrs.append("sym_visibility", prop.sym_visibility); } ::llvm::LogicalResult ModuleOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_BuiltinOps1(attr, "sym_name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSymVisibilityAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_BuiltinOps1(attr, "sym_visibility", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ModuleOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.sym_name))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.sym_visibility))) return ::mlir::failure(); return ::mlir::success(); } void ModuleOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.sym_name); writer.writeOptionalAttribute(prop.sym_visibility); } ::std::optional< ::llvm::StringRef > ModuleOp::getSymName() { auto attr = getSymNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::llvm::StringRef > ModuleOp::getSymVisibility() { auto attr = getSymVisibilityAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } void ModuleOp::setSymName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().sym_name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void ModuleOp::setSymVisibility(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().sym_visibility; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } ModuleOp ModuleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, std::optional name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ModuleOp ModuleOp::create(::mlir::ImplicitLocOpBuilder &builder, std::optional name) { return create(builder, builder.getLoc(), std::forward(name)); } ::llvm::LogicalResult ModuleOp::verifyInvariantsImpl() { auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; auto tblgen_sym_visibility = getProperties().sym_visibility; (void)tblgen_sym_visibility; if (::mlir::failed(__mlir_ods_local_attr_constraint_BuiltinOps1(*this, tblgen_sym_name, "sym_name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_BuiltinOps1(*this, tblgen_sym_visibility, "sym_visibility"))) return ::mlir::failure(); { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_BuiltinOps1(*this, region, "bodyRegion", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ModuleOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ModuleOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::StringAttr sym_nameAttr; std::unique_ptr<::mlir::Region> bodyRegionRegion = std::make_unique<::mlir::Region>(); // Parsing an optional symbol name doesn't fail, so no need to check the // result. (void)parser.parseOptionalSymbolName(sym_nameAttr); if (sym_nameAttr) result.getOrAddProperties().sym_name = sym_nameAttr; if (sym_nameAttr) { } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDictWithKeyword(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.parseRegion(*bodyRegionRegion)) return ::mlir::failure(); if (bodyRegionRegion->empty()) bodyRegionRegion->emplaceBlock(); result.addRegion(std::move(bodyRegionRegion)); return ::mlir::success(); } void ModuleOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getSymNameAttr()) { _odsPrinter << ' '; _odsPrinter.printSymbolName(getSymNameAttr().getValue()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("sym_name"); _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' '; _odsPrinter.printRegion(getBodyRegion()); } } // namespace mlir MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::ModuleOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::detail::ModuleOpGenericAdaptorBase::Properties) namespace mlir { //===----------------------------------------------------------------------===// // ::mlir::UnrealizedConversionCastOp definitions //===----------------------------------------------------------------------===// namespace detail { UnrealizedConversionCastOpGenericAdaptorBase::UnrealizedConversionCastOpGenericAdaptorBase(UnrealizedConversionCastOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair UnrealizedConversionCastOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } } // namespace detail UnrealizedConversionCastOpAdaptor::UnrealizedConversionCastOpAdaptor(UnrealizedConversionCastOp op) : UnrealizedConversionCastOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult UnrealizedConversionCastOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair UnrealizedConversionCastOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange UnrealizedConversionCastOp::getInputsMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } std::pair UnrealizedConversionCastOp::getODSResultIndexAndLength(unsigned index) { bool isVariadic[] = {true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumResults() - 0) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::llvm::LogicalResult UnrealizedConversionCastOp::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 UnrealizedConversionCastOp::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 UnrealizedConversionCastOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional UnrealizedConversionCastOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void UnrealizedConversionCastOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void UnrealizedConversionCastOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult UnrealizedConversionCastOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void UnrealizedConversionCastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); odsState.addTypes(resultTypes); } UnrealizedConversionCastOp UnrealizedConversionCastOp::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__; } UnrealizedConversionCastOp UnrealizedConversionCastOp::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 UnrealizedConversionCastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); odsState.addTypes(resultTypes); } UnrealizedConversionCastOp UnrealizedConversionCastOp::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__; } UnrealizedConversionCastOp UnrealizedConversionCastOp::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 UnrealizedConversionCastOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_BuiltinOps1(*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_BuiltinOps1(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult UnrealizedConversionCastOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult UnrealizedConversionCastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> inputsOperands; ::llvm::SMLoc inputsOperandsLoc; (void)inputsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> inputsTypes; ::llvm::SmallVector<::mlir::Type, 1> outputsTypes; inputsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(inputsOperands)) return ::mlir::failure(); if (!inputsOperands.empty()) { if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(inputsTypes)) return ::mlir::failure(); } if (parser.parseKeyword("to")) return ::mlir::failure(); if (parser.parseTypeList(outputsTypes)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } result.addTypes(outputsTypes); if (parser.resolveOperands(inputsOperands, inputsTypes, inputsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void UnrealizedConversionCastOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (!getInputs().empty()) { _odsPrinter << ' '; _odsPrinter << getInputs(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getInputs().getTypes(); } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; _odsPrinter << getOutputs().getTypes(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } void UnrealizedConversionCastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::UnrealizedConversionCastOp) #endif // GET_OP_CLASSES