/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |* *| |* Op Definitions *| |* *| |* Automatically generated file, do not edit! *| |* From: OpenACCOps.td *| |* *| \*===----------------------------------------------------------------------===*/ #ifdef GET_OP_LIST #undef GET_OP_LIST ::mlir::acc::AtomicCaptureOp, ::mlir::acc::AtomicReadOp, ::mlir::acc::AtomicUpdateOp, ::mlir::acc::AtomicWriteOp, ::mlir::acc::AttachOp, ::mlir::acc::CacheOp, ::mlir::acc::ComputeRegionOp, ::mlir::acc::CopyinOp, ::mlir::acc::CopyoutOp, ::mlir::acc::CreateOp, ::mlir::acc::DataBoundsOp, ::mlir::acc::DataOp, ::mlir::acc::DeclareDeviceResidentOp, ::mlir::acc::DeclareEnterOp, ::mlir::acc::DeclareExitOp, ::mlir::acc::DeclareLinkOp, ::mlir::acc::DeclareOp, ::mlir::acc::DeleteOp, ::mlir::acc::DetachOp, ::mlir::acc::DevicePtrOp, ::mlir::acc::EnterDataOp, ::mlir::acc::ExitDataOp, ::mlir::acc::FirstprivateMapInitialOp, ::mlir::acc::FirstprivateOp, ::mlir::acc::FirstprivateRecipeOp, ::mlir::acc::GetDevicePtrOp, ::mlir::acc::GetExtentOp, ::mlir::acc::GetLowerboundOp, ::mlir::acc::GetStrideOp, ::mlir::acc::GetUpperboundOp, ::mlir::acc::GlobalConstructorOp, ::mlir::acc::GlobalDestructorOp, ::mlir::acc::HostDataOp, ::mlir::acc::InitOp, ::mlir::acc::KernelEnvironmentOp, ::mlir::acc::KernelsOp, ::mlir::acc::LoopOp, ::mlir::acc::NoCreateOp, ::mlir::acc::ParWidthOp, ::mlir::acc::ParallelOp, ::mlir::acc::PredicateRegionOp, ::mlir::acc::PresentOp, ::mlir::acc::PrivateLocalOp, ::mlir::acc::PrivateOp, ::mlir::acc::PrivateRecipeOp, ::mlir::acc::PrivatizeOp, ::mlir::acc::ReductionAccumulateOp, ::mlir::acc::ReductionCombineOp, ::mlir::acc::ReductionCombineRegionOp, ::mlir::acc::ReductionInitOp, ::mlir::acc::ReductionOp, ::mlir::acc::ReductionRecipeOp, ::mlir::acc::RoutineOp, ::mlir::acc::SerialOp, ::mlir::acc::SetOp, ::mlir::acc::ShutdownOp, ::mlir::acc::TerminatorOp, ::mlir::acc::UnwrapPrivateOp, ::mlir::acc::UpdateDeviceOp, ::mlir::acc::UpdateHostOp, ::mlir::acc::UpdateOp, ::mlir::acc::UseDeviceOp, ::mlir::acc::WaitOp, ::mlir::acc::YieldOp #endif // GET_OP_LIST #ifdef GET_OP_CLASSES #undef GET_OP_CLASSES //===----------------------------------------------------------------------===// // Local Utility Method Definitions //===----------------------------------------------------------------------===// static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps1( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((type.isSignlessInteger(1)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be 1-bit signless integer, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps2( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((::llvm::isa<::mlir::acc::PointerLikeType>(type)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be pointer-like type, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps3( ::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_OpenACCOps4( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::acc::PointerLikeType>(type))) || ((::llvm::isa<::mlir::acc::MappableType>(type))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be any pointer or mappable, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps5( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((::llvm::isa<::mlir::acc::PointerLikeType>(type)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be PointerLikeType instance, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps6( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((::llvm::isa<::mlir::acc::DataBoundsType>(type)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be variadic of Type for representing acc data clause bounds information, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps7( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::IntegerType>(type))) || ((::llvm::isa<::mlir::IndexType>(type))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be variadic of integer or index, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps8( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((::llvm::isa<::mlir::IndexType>(type)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be variadic of index, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps9( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(!((::llvm::isa<::mlir::TokenType>(type))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be variadic of any non-token type, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps10( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((::llvm::isa<::mlir::gpu::AsyncTokenType>(type)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be GPU async token type, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps11( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::IntegerType>(type))) || ((::llvm::isa<::mlir::IndexType>(type))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be integer or index, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps12( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((::llvm::isa<::mlir::acc::DataBoundsType>(type)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be Type for representing acc data clause bounds information, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps13( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::acc::PointerLikeType>(type))) || ((::llvm::isa<::mlir::acc::MappableType>(type))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be variadic of any pointer or mappable, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps14( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((::llvm::isa<::mlir::acc::DeclareTokenType>(type)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be declare token type, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps15( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((::llvm::isa<::mlir::IndexType>(type)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be index, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps16( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!((::llvm::isa<::mlir::acc::PrivateType>(type)))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be Handle type for privatized storage across parallel dimensions, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_type_constraint_OpenACCOps17( ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, unsigned valueIndex) { if (!(((::llvm::isa<::mlir::IntegerType>(type))) || ((::llvm::isa<::mlir::FloatType>(type))) || ((::llvm::isa<::mlir::ComplexType>(type))))) { return op->emitOpError(valueKind) << " #" << valueIndex << " must be integer or floating-point or complex-type, but got " << type; } return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps1( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::TypeAttr>(attr))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))) && ((true)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: any type attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps1( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps1(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps2( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: device type array attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps2( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps2(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps3( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::acc::DataClauseAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: data clauses supported by OpenACC"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps3( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps3(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps4( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::BoolAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: bool attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps4( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps4(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps5( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Captures data clause modifiers"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps5( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps5(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps6( ::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_OpenACCOps6( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps6(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps7( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::SymbolRefAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: symbol reference attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps7( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps7(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps8( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::FlatSymbolRefAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: flat symbol reference attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps8( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps8(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps9( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: i32 dense array attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps9( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps9(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps10( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::BoolAttr>(attr))); })))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: 1-bit boolean array attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps10( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps10(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps11( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::acc::ClauseDefaultValueAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: DefaultValue Clause"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps11( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps11(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps12( ::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_OpenACCOps12( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps12(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps13( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Device type attributes"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps13( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps13(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps14( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: i1 dense array attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps14( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps14(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps15( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); })))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: 64-bit integer array attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps15( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps15(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps16( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::GangArgTypeAttr>(attr))); })))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: gang arg type array attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps16( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps16(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps17( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::acc::CombinedConstructsTypeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: Differentiate between combined constructs"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps17( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps17(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps18( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::acc::GPUParallelDimAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: GPU parallel dimension for use in OpenACC parallelism assignment."; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps18( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps18(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps19( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::acc::GPUParallelDimsAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: List of GPU parallel dimensions for use in OpenACC parallelism assignment."; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps19( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps19(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps20( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::acc::ReductionOperatorAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: built-in reduction operations supported by OpenACC"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps20( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps20(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps21( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); })))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: symbol ref array attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps21( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps21(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps22( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::StringAttr>(attr))); })))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: string array attribute"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps22( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps22(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps23( ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { if (attr && !((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr)))) return emitError() << "attribute '" << attrName << "' failed to satisfy constraint: built-in device type supported by OpenACC"; return ::mlir::success(); } static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_OpenACCOps23( ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { return __mlir_ods_local_attr_constraint_OpenACCOps23(attr, attrName, [op]() { return op->emitOpError(); }); } static ::llvm::LogicalResult __mlir_ods_local_region_constraint_OpenACCOps1( ::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(); } static ::llvm::LogicalResult __mlir_ods_local_region_constraint_OpenACCOps2( ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, unsigned regionIndex) { if (!((true))) { return op->emitOpError("region #") << regionIndex << (regionName.empty() ? " " : " ('" + regionName + "') ") << "failed to verify constraint: any region"; } return ::mlir::success(); } namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::AtomicCaptureOp definitions //===----------------------------------------------------------------------===// namespace detail { AtomicCaptureOpGenericAdaptorBase::AtomicCaptureOpGenericAdaptorBase(AtomicCaptureOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair AtomicCaptureOpGenericAdaptorBase::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 AtomicCaptureOpAdaptor::AtomicCaptureOpAdaptor(AtomicCaptureOp op) : AtomicCaptureOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AtomicCaptureOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair AtomicCaptureOp::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 AtomicCaptureOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult AtomicCaptureOp::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 AtomicCaptureOp::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 AtomicCaptureOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional AtomicCaptureOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void AtomicCaptureOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void AtomicCaptureOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult AtomicCaptureOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void AtomicCaptureOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value ifCond) { if (ifCond) odsState.addOperands(ifCond); (void)odsState.addRegion(); } AtomicCaptureOp AtomicCaptureOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicCaptureOp AtomicCaptureOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(ifCond)); } void AtomicCaptureOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond) { if (ifCond) odsState.addOperands(ifCond); (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } AtomicCaptureOp AtomicCaptureOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicCaptureOp AtomicCaptureOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ifCond)); } void AtomicCaptureOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AtomicCaptureOp AtomicCaptureOp::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__; } AtomicCaptureOp AtomicCaptureOp::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 AtomicCaptureOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AtomicCaptureOp AtomicCaptureOp::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__; } AtomicCaptureOp AtomicCaptureOp::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 AtomicCaptureOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); if (valueGroup0.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup0.size(); } for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps1(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult AtomicCaptureOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult AtomicCaptureOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); bool ifClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseRegion(*regionRegion)) return ::mlir::failure(); ensureTerminator(*regionRegion, parser.getBuilder(), result.location); { 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.addRegion(std::move(regionRegion)); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void AtomicCaptureOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } _odsPrinter << ' '; { bool printTerminator = true; if (auto *term = getRegion().empty() ? nullptr : getRegion().begin()->getTerminator()) { printTerminator = !term->getAttrDictionary().empty() || term->getNumOperands() != 0 || term->getNumResults() != 0; } _odsPrinter.printRegion(getRegion(), /*printEntryBlockArgs=*/true, /*printBlockTerminators=*/printTerminator); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::AtomicCaptureOp) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::AtomicReadOp definitions //===----------------------------------------------------------------------===// namespace detail { AtomicReadOpGenericAdaptorBase::AtomicReadOpGenericAdaptorBase(AtomicReadOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair AtomicReadOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::Type AtomicReadOpGenericAdaptorBase::getElementType() { auto attr = getElementTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } } // namespace detail AtomicReadOpAdaptor::AtomicReadOpAdaptor(AtomicReadOp op) : AtomicReadOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AtomicReadOpAdaptor::verify(::mlir::Location loc) { auto tblgen_element_type = getProperties().element_type; (void)tblgen_element_type; if (!tblgen_element_type) return emitError(loc, "'acc.atomic.read' op requires attribute 'element_type'"); if (tblgen_element_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_element_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_element_type).getValue()))) && ((true)))) return emitError(loc, "'acc.atomic.read' op attribute 'element_type' failed to satisfy constraint: any type attribute"); return ::mlir::success(); } std::pair AtomicReadOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange AtomicReadOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult AtomicReadOp::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.element_type; auto attr = dict.get("element_type"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `element_type` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute AtomicReadOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.element_type; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("element_type", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code AtomicReadOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.element_type.getAsOpaquePointer())); } std::optional AtomicReadOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "element_type") return prop.element_type; return std::nullopt; } void AtomicReadOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "element_type") { prop.element_type = ::llvm::dyn_cast_or_null>(value); return; } } void AtomicReadOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.element_type) attrs.append("element_type", prop.element_type); } ::llvm::LogicalResult AtomicReadOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getElementTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "element_type", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult AtomicReadOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.element_type))) return ::mlir::failure(); return ::mlir::success(); } void AtomicReadOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.element_type); } ::mlir::Type AtomicReadOp::getElementType() { auto attr = getElementTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } void AtomicReadOp::setElementType(::mlir::Type attrValue) { getProperties().element_type = ::mlir::TypeAttr::get(attrValue); } void AtomicReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, ::mlir::Value v, ::mlir::TypeAttr element_type, /*optional*/::mlir::Value ifCond) { odsState.addOperands(x); odsState.addOperands(v); if (ifCond) odsState.addOperands(ifCond); odsState.getOrAddProperties().element_type = element_type; } AtomicReadOp AtomicReadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value x, ::mlir::Value v, ::mlir::TypeAttr element_type, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(x), std::forward(v), std::forward(element_type), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicReadOp AtomicReadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value x, ::mlir::Value v, ::mlir::TypeAttr element_type, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(x), std::forward(v), std::forward(element_type), std::forward(ifCond)); } void AtomicReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value v, ::mlir::TypeAttr element_type, /*optional*/::mlir::Value ifCond) { odsState.addOperands(x); odsState.addOperands(v); if (ifCond) odsState.addOperands(ifCond); odsState.getOrAddProperties().element_type = element_type; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } AtomicReadOp AtomicReadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value v, ::mlir::TypeAttr element_type, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(x), std::forward(v), std::forward(element_type), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicReadOp AtomicReadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value v, ::mlir::TypeAttr element_type, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(x), std::forward(v), std::forward(element_type), std::forward(ifCond)); } void AtomicReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, ::mlir::Value v, ::mlir::Type element_type, /*optional*/::mlir::Value ifCond) { odsState.addOperands(x); odsState.addOperands(v); if (ifCond) odsState.addOperands(ifCond); odsState.getOrAddProperties().element_type = ::mlir::TypeAttr::get(element_type); } AtomicReadOp AtomicReadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value x, ::mlir::Value v, ::mlir::Type element_type, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(x), std::forward(v), std::forward(element_type), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicReadOp AtomicReadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value x, ::mlir::Value v, ::mlir::Type element_type, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(x), std::forward(v), std::forward(element_type), std::forward(ifCond)); } void AtomicReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value v, ::mlir::Type element_type, /*optional*/::mlir::Value ifCond) { odsState.addOperands(x); odsState.addOperands(v); if (ifCond) odsState.addOperands(ifCond); odsState.getOrAddProperties().element_type = ::mlir::TypeAttr::get(element_type); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } AtomicReadOp AtomicReadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value v, ::mlir::Type element_type, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(x), std::forward(v), std::forward(element_type), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicReadOp AtomicReadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value v, ::mlir::Type element_type, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(x), std::forward(v), std::forward(element_type), std::forward(ifCond)); } void AtomicReadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } AtomicReadOp AtomicReadOp::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__; } AtomicReadOp AtomicReadOp::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 AtomicReadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AtomicReadOp AtomicReadOp::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__; } AtomicReadOp AtomicReadOp::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 AtomicReadOp::verifyInvariantsImpl() { auto tblgen_element_type = getProperties().element_type; (void)tblgen_element_type; if (!tblgen_element_type) return emitOpError("requires attribute 'element_type'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_element_type, "element_type"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); if (valueGroup2.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup2.size(); } for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult AtomicReadOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult AtomicReadOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand vRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> vOperands(&vRawOperand, 1); ::llvm::SMLoc vOperandsLoc; (void)vOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand xRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> xOperands(&xRawOperand, 1); ::llvm::SMLoc xOperandsLoc; (void)xOperandsLoc; ::mlir::Type vRawType{}; ::llvm::ArrayRef<::mlir::Type> vTypes(&vRawType, 1); ::mlir::Type xRawType{}; ::llvm::ArrayRef<::mlir::Type> xTypes(&xRawType, 1); ::mlir::TypeAttr element_typeAttr; bool ifClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } vOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(vRawOperand)) return ::mlir::failure(); if (parser.parseEqual()) return ::mlir::failure(); xOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(xRawOperand)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); { ::mlir::acc::PointerLikeType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); vRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::acc::PointerLikeType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); xRawType = type; } if (parser.parseComma()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(element_typeAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (element_typeAttr) result.getOrAddProperties().element_type = element_typeAttr; { 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(); } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (parser.resolveOperands(xOperands, xTypes, xOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(vOperands, vTypes, vOperandsLoc, result.operands)) return ::mlir::failure(); if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void AtomicReadOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } _odsPrinter << ' '; _odsPrinter << getV(); _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter << getX(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getV().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::acc::PointerLikeType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getX().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::acc::PointerLikeType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getElementTypeAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("element_type"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::AtomicReadOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::AtomicReadOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::AtomicUpdateOp definitions //===----------------------------------------------------------------------===// namespace detail { AtomicUpdateOpGenericAdaptorBase::AtomicUpdateOpGenericAdaptorBase(AtomicUpdateOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair AtomicUpdateOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } } // namespace detail AtomicUpdateOpAdaptor::AtomicUpdateOpAdaptor(AtomicUpdateOp op) : AtomicUpdateOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AtomicUpdateOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair AtomicUpdateOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 1) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange AtomicUpdateOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult AtomicUpdateOp::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 AtomicUpdateOp::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 AtomicUpdateOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional AtomicUpdateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void AtomicUpdateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void AtomicUpdateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult AtomicUpdateOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void AtomicUpdateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, /*optional*/::mlir::Value ifCond) { odsState.addOperands(x); if (ifCond) odsState.addOperands(ifCond); (void)odsState.addRegion(); } AtomicUpdateOp AtomicUpdateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value x, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(x), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicUpdateOp AtomicUpdateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value x, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(x), std::forward(ifCond)); } void AtomicUpdateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, /*optional*/::mlir::Value ifCond) { odsState.addOperands(x); if (ifCond) odsState.addOperands(ifCond); (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } AtomicUpdateOp AtomicUpdateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value x, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(x), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicUpdateOp AtomicUpdateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value x, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(x), std::forward(ifCond)); } void AtomicUpdateOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AtomicUpdateOp AtomicUpdateOp::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__; } AtomicUpdateOp AtomicUpdateOp::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 AtomicUpdateOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AtomicUpdateOp AtomicUpdateOp::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__; } AtomicUpdateOp AtomicUpdateOp::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 AtomicUpdateOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps1(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult AtomicUpdateOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } void AtomicUpdateOp::getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context) { results.add(canonicalize); } ::mlir::ParseResult AtomicUpdateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand xRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> xOperands(&xRawOperand, 1); ::llvm::SMLoc xOperandsLoc; (void)xOperandsLoc; ::mlir::Type xRawType{}; ::llvm::ArrayRef<::mlir::Type> xTypes(&xRawType, 1); std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); bool ifClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } xOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(xRawOperand)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); { ::mlir::acc::PointerLikeType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); xRawType = type; } if (parser.parseRegion(*regionRegion)) return ::mlir::failure(); ensureTerminator(*regionRegion, parser.getBuilder(), result.location); { 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.addRegion(std::move(regionRegion)); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (parser.resolveOperands(xOperands, xTypes, xOperandsLoc, result.operands)) return ::mlir::failure(); if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void AtomicUpdateOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } _odsPrinter << ' '; _odsPrinter << getX(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getX().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::acc::PointerLikeType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' '; { bool printTerminator = true; if (auto *term = getRegion().empty() ? nullptr : getRegion().begin()->getTerminator()) { printTerminator = !term->getAttrDictionary().empty() || term->getNumOperands() != 0 || term->getNumResults() != 0; } _odsPrinter.printRegion(getRegion(), /*printEntryBlockArgs=*/true, /*printBlockTerminators=*/printTerminator); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } void AtomicUpdateOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { { auto valueRange = getODSOperandIndexAndLength(0); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Read::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get()); } } { auto valueRange = getODSOperandIndexAndLength(0); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get()); } } } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::AtomicUpdateOp) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::AtomicWriteOp definitions //===----------------------------------------------------------------------===// namespace detail { AtomicWriteOpGenericAdaptorBase::AtomicWriteOpGenericAdaptorBase(AtomicWriteOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair AtomicWriteOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (odsOperandsSize - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } } // namespace detail AtomicWriteOpAdaptor::AtomicWriteOpAdaptor(AtomicWriteOp op) : AtomicWriteOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AtomicWriteOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair AtomicWriteOp::getODSOperandIndexAndLength(unsigned index) { bool isVariadic[] = {false, false, true}; int prevVariadicCount = 0; for (unsigned i = 0; i < index; ++i) if (isVariadic[i]) ++prevVariadicCount; // Calculate how many dynamic values a static variadic operand corresponds to. // This assumes all static variadic operands have the same dynamic value count. int variadicSize = (getOperation()->getNumOperands() - 2) / 1; // `index` passed in as the parameter is the static index which counts each // operand (variadic or not) as size 1. So here for each previous static variadic // operand, we need to offset by (variadicSize - 1) to get where the dynamic // value pack for this static operand starts. int start = index + (variadicSize - 1) * prevVariadicCount; int size = isVariadic[index] ? variadicSize : 1; return {start, size}; } ::mlir::MutableOperandRange AtomicWriteOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult AtomicWriteOp::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 AtomicWriteOp::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 AtomicWriteOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional AtomicWriteOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void AtomicWriteOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void AtomicWriteOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult AtomicWriteOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void AtomicWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, ::mlir::Value expr, /*optional*/::mlir::Value ifCond) { odsState.addOperands(x); odsState.addOperands(expr); if (ifCond) odsState.addOperands(ifCond); } AtomicWriteOp AtomicWriteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value x, ::mlir::Value expr, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(x), std::forward(expr), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicWriteOp AtomicWriteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value x, ::mlir::Value expr, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(x), std::forward(expr), std::forward(ifCond)); } void AtomicWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value expr, /*optional*/::mlir::Value ifCond) { odsState.addOperands(x); odsState.addOperands(expr); if (ifCond) odsState.addOperands(ifCond); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } AtomicWriteOp AtomicWriteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value expr, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(x), std::forward(expr), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AtomicWriteOp AtomicWriteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value expr, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(x), std::forward(expr), std::forward(ifCond)); } void AtomicWriteOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AtomicWriteOp AtomicWriteOp::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__; } AtomicWriteOp AtomicWriteOp::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 AtomicWriteOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } AtomicWriteOp AtomicWriteOp::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__; } AtomicWriteOp AtomicWriteOp::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 AtomicWriteOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps3(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); if (valueGroup2.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup2.size(); } for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult AtomicWriteOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult AtomicWriteOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand xRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> xOperands(&xRawOperand, 1); ::llvm::SMLoc xOperandsLoc; (void)xOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand exprRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> exprOperands(&exprRawOperand, 1); ::llvm::SMLoc exprOperandsLoc; (void)exprOperandsLoc; ::mlir::Type xRawType{}; ::llvm::ArrayRef<::mlir::Type> xTypes(&xRawType, 1); ::mlir::Type exprRawType{}; ::llvm::ArrayRef<::mlir::Type> exprTypes(&exprRawType, 1); bool ifClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } xOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(xRawOperand)) return ::mlir::failure(); if (parser.parseEqual()) return ::mlir::failure(); exprOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(exprRawOperand)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); { ::mlir::acc::PointerLikeType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); xRawType = type; } if (parser.parseComma()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); exprRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (parser.resolveOperands(xOperands, xTypes, xOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(exprOperands, exprTypes, exprOperandsLoc, result.operands)) return ::mlir::failure(); if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void AtomicWriteOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } _odsPrinter << ' '; _odsPrinter << getX(); _odsPrinter << ' ' << "="; _odsPrinter << ' '; _odsPrinter << getExpr(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getX().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::acc::PointerLikeType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ","; _odsPrinter << ' '; { auto type = getExpr().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::AtomicWriteOp) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::AttachOp definitions //===----------------------------------------------------------------------===// namespace detail { AttachOpGenericAdaptorBase::AttachOpGenericAdaptorBase(AttachOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair AttachOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type AttachOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > AttachOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > AttachOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr AttachOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause AttachOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr AttachOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool AttachOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr AttachOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool AttachOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr AttachOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier AttachOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > AttachOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > AttachOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail AttachOpAdaptor::AttachOpAdaptor(AttachOp op) : AttachOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult AttachOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.attach' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.attach' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.attach' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.attach' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.attach' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.attach' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.attach' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.attach' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.attach' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.attach' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair AttachOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange AttachOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange AttachOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange AttachOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult AttachOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute AttachOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code AttachOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional AttachOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void AttachOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void AttachOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult AttachOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult AttachOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void AttachOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type AttachOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > AttachOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > AttachOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause AttachOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool AttachOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool AttachOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier AttachOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > AttachOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > AttachOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void AttachOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void AttachOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void AttachOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void AttachOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void AttachOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void AttachOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void AttachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } AttachOp AttachOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AttachOp AttachOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void AttachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } AttachOp AttachOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AttachOp AttachOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void AttachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } AttachOp AttachOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AttachOp AttachOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void AttachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } AttachOp AttachOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AttachOp AttachOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void AttachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } AttachOp AttachOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AttachOp AttachOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void AttachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AttachOp AttachOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AttachOp AttachOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void AttachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } AttachOp AttachOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AttachOp AttachOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void AttachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } AttachOp AttachOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } AttachOp AttachOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void AttachOp::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."); } } AttachOp AttachOp::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__; } AttachOp AttachOp::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 AttachOp::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); } AttachOp AttachOp::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__; } AttachOp AttachOp::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 AttachOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_attach); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult AttachOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult AttachOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult AttachOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void AttachOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_attach))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::AttachOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::AttachOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::CacheOp definitions //===----------------------------------------------------------------------===// namespace detail { CacheOpGenericAdaptorBase::CacheOpGenericAdaptorBase(CacheOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair CacheOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type CacheOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > CacheOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > CacheOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr CacheOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause CacheOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr CacheOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool CacheOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr CacheOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool CacheOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr CacheOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier CacheOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > CacheOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > CacheOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail CacheOpAdaptor::CacheOpAdaptor(CacheOp op) : CacheOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CacheOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.cache' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.cache' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.cache' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.cache' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.cache' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.cache' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.cache' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.cache' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.cache' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.cache' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair CacheOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange CacheOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange CacheOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange CacheOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult CacheOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute CacheOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code CacheOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional CacheOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void CacheOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void CacheOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult CacheOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CacheOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void CacheOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type CacheOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > CacheOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > CacheOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause CacheOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool CacheOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool CacheOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier CacheOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > CacheOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > CacheOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void CacheOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void CacheOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CacheOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void CacheOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void CacheOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CacheOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void CacheOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } CacheOp CacheOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CacheOp CacheOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void CacheOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } CacheOp CacheOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CacheOp CacheOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void CacheOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } CacheOp CacheOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CacheOp CacheOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void CacheOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } CacheOp CacheOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CacheOp CacheOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void CacheOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } CacheOp CacheOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CacheOp CacheOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void CacheOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CacheOp CacheOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CacheOp CacheOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void CacheOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } CacheOp CacheOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CacheOp CacheOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void CacheOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CacheOp CacheOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CacheOp CacheOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void CacheOp::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."); } } CacheOp CacheOp::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__; } CacheOp CacheOp::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 CacheOp::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); } CacheOp CacheOp::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__; } CacheOp CacheOp::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 CacheOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_cache); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult CacheOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CacheOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult CacheOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void CacheOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_cache))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::CacheOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::CacheOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::ComputeRegionOp definitions //===----------------------------------------------------------------------===// namespace detail { ComputeRegionOpGenericAdaptorBase::ComputeRegionOpGenericAdaptorBase(ComputeRegionOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ComputeRegionOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::llvm::StringRef ComputeRegionOpGenericAdaptorBase::getOrigin() { auto attr = getOriginAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > ComputeRegionOpGenericAdaptorBase::getKernelFuncName() { auto attr = getKernelFuncNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::llvm::StringRef > ComputeRegionOpGenericAdaptorBase::getKernelModuleName() { auto attr = getKernelModuleNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } } // namespace detail ComputeRegionOpAdaptor::ComputeRegionOpAdaptor(ComputeRegionOp op) : ComputeRegionOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ComputeRegionOpAdaptor::verify(::mlir::Location loc) { auto tblgen_kernel_func_name = getProperties().kernel_func_name; (void)tblgen_kernel_func_name; auto tblgen_kernel_module_name = getProperties().kernel_module_name; (void)tblgen_kernel_module_name; auto tblgen_origin = getProperties().origin; (void)tblgen_origin; if (!tblgen_origin) return emitError(loc, "'acc.compute_region' op requires attribute 'origin'"); if (tblgen_origin && !((::llvm::isa<::mlir::StringAttr>(tblgen_origin)))) return emitError(loc, "'acc.compute_region' op attribute 'origin' failed to satisfy constraint: string attribute"); if (tblgen_kernel_func_name && !((::llvm::isa<::mlir::FlatSymbolRefAttr>(tblgen_kernel_func_name)))) return emitError(loc, "'acc.compute_region' op attribute 'kernel_func_name' failed to satisfy constraint: flat symbol reference attribute"); if (tblgen_kernel_module_name && !((::llvm::isa<::mlir::FlatSymbolRefAttr>(tblgen_kernel_module_name)))) return emitError(loc, "'acc.compute_region' op attribute 'kernel_module_name' failed to satisfy constraint: flat symbol reference attribute"); return ::mlir::success(); } std::pair ComputeRegionOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange ComputeRegionOp::getLaunchArgsMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ComputeRegionOp::getInputArgsMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ComputeRegionOp::getStreamMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } std::pair ComputeRegionOp::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 ComputeRegionOp::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.kernel_func_name; auto attr = dict.get("kernel_func_name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kernel_func_name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kernel_module_name; auto attr = dict.get("kernel_module_name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kernel_module_name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.origin; auto attr = dict.get("origin"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `origin` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute ComputeRegionOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.kernel_func_name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kernel_func_name", propStorage)); } { const auto &propStorage = prop.kernel_module_name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("kernel_module_name", propStorage)); } { const auto &propStorage = prop.origin; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("origin", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ComputeRegionOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.kernel_func_name.getAsOpaquePointer()), llvm::hash_value(prop.kernel_module_name.getAsOpaquePointer()), llvm::hash_value(prop.origin.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional ComputeRegionOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "kernel_func_name") return prop.kernel_func_name; if (name == "kernel_module_name") return prop.kernel_module_name; if (name == "origin") return prop.origin; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void ComputeRegionOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "kernel_func_name") { prop.kernel_func_name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "kernel_module_name") { prop.kernel_module_name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "origin") { prop.origin = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void ComputeRegionOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.kernel_func_name) attrs.append("kernel_func_name", prop.kernel_func_name); if (prop.kernel_module_name) attrs.append("kernel_module_name", prop.kernel_module_name); if (prop.origin) attrs.append("origin", prop.origin); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult ComputeRegionOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getKernelFuncNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps8(attr, "kernel_func_name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getKernelModuleNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps8(attr, "kernel_module_name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getOriginAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "origin", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ComputeRegionOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.kernel_func_name))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.kernel_module_name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readAttribute(prop.origin))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void ComputeRegionOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.kernel_func_name); writer.writeOptionalAttribute(prop.kernel_module_name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeAttribute(prop.origin); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::llvm::StringRef ComputeRegionOp::getOrigin() { auto attr = getOriginAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > ComputeRegionOp::getKernelFuncName() { auto attr = getKernelFuncNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::llvm::StringRef > ComputeRegionOp::getKernelModuleName() { auto attr = getKernelModuleNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } void ComputeRegionOp::setOrigin(::llvm::StringRef attrValue) { getProperties().origin = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue); } void ComputeRegionOp::setKernelFuncName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().kernel_func_name; if (attrValue) odsProp = ::mlir::SymbolRefAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void ComputeRegionOp::setKernelModuleName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().kernel_module_name; if (attrValue) odsProp = ::mlir::SymbolRefAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void ComputeRegionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange launchArgs, ::mlir::ValueRange inputArgs, /*optional*/::mlir::Value stream, ::mlir::StringAttr origin, /*optional*/::mlir::FlatSymbolRefAttr kernel_func_name, /*optional*/::mlir::FlatSymbolRefAttr kernel_module_name) { odsState.addOperands(launchArgs); odsState.addOperands(inputArgs); if (stream) odsState.addOperands(stream); ::llvm::copy(::llvm::ArrayRef({static_cast(launchArgs.size()), static_cast(inputArgs.size()), (stream ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().origin = origin; if (kernel_func_name) { odsState.getOrAddProperties().kernel_func_name = kernel_func_name; } if (kernel_module_name) { odsState.getOrAddProperties().kernel_module_name = kernel_module_name; } (void)odsState.addRegion(); odsState.addTypes(results); } ComputeRegionOp ComputeRegionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange results, ::mlir::ValueRange launchArgs, ::mlir::ValueRange inputArgs, /*optional*/::mlir::Value stream, ::mlir::StringAttr origin, /*optional*/::mlir::FlatSymbolRefAttr kernel_func_name, /*optional*/::mlir::FlatSymbolRefAttr kernel_module_name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(results), std::forward(launchArgs), std::forward(inputArgs), std::forward(stream), std::forward(origin), std::forward(kernel_func_name), std::forward(kernel_module_name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ComputeRegionOp ComputeRegionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange results, ::mlir::ValueRange launchArgs, ::mlir::ValueRange inputArgs, /*optional*/::mlir::Value stream, ::mlir::StringAttr origin, /*optional*/::mlir::FlatSymbolRefAttr kernel_func_name, /*optional*/::mlir::FlatSymbolRefAttr kernel_module_name) { return create(builder, builder.getLoc(), std::forward(results), std::forward(launchArgs), std::forward(inputArgs), std::forward(stream), std::forward(origin), std::forward(kernel_func_name), std::forward(kernel_module_name)); } void ComputeRegionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange launchArgs, ::mlir::ValueRange inputArgs, /*optional*/::mlir::Value stream, ::llvm::StringRef origin, /*optional*/::mlir::FlatSymbolRefAttr kernel_func_name, /*optional*/::mlir::FlatSymbolRefAttr kernel_module_name) { odsState.addOperands(launchArgs); odsState.addOperands(inputArgs); if (stream) odsState.addOperands(stream); ::llvm::copy(::llvm::ArrayRef({static_cast(launchArgs.size()), static_cast(inputArgs.size()), (stream ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().origin = odsBuilder.getStringAttr(origin); if (kernel_func_name) { odsState.getOrAddProperties().kernel_func_name = kernel_func_name; } if (kernel_module_name) { odsState.getOrAddProperties().kernel_module_name = kernel_module_name; } (void)odsState.addRegion(); odsState.addTypes(results); } ComputeRegionOp ComputeRegionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange results, ::mlir::ValueRange launchArgs, ::mlir::ValueRange inputArgs, /*optional*/::mlir::Value stream, ::llvm::StringRef origin, /*optional*/::mlir::FlatSymbolRefAttr kernel_func_name, /*optional*/::mlir::FlatSymbolRefAttr kernel_module_name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(results), std::forward(launchArgs), std::forward(inputArgs), std::forward(stream), std::forward(origin), std::forward(kernel_func_name), std::forward(kernel_module_name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ComputeRegionOp ComputeRegionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange results, ::mlir::ValueRange launchArgs, ::mlir::ValueRange inputArgs, /*optional*/::mlir::Value stream, ::llvm::StringRef origin, /*optional*/::mlir::FlatSymbolRefAttr kernel_func_name, /*optional*/::mlir::FlatSymbolRefAttr kernel_module_name) { return create(builder, builder.getLoc(), std::forward(results), std::forward(launchArgs), std::forward(inputArgs), std::forward(stream), std::forward(origin), std::forward(kernel_func_name), std::forward(kernel_module_name)); } void ComputeRegionOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); 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."); } } ComputeRegionOp ComputeRegionOp::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__; } ComputeRegionOp ComputeRegionOp::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 ComputeRegionOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); odsState.addTypes(resultTypes); } ComputeRegionOp ComputeRegionOp::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__; } ComputeRegionOp ComputeRegionOp::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 ComputeRegionOp::verifyInvariantsImpl() { auto tblgen_kernel_func_name = getProperties().kernel_func_name; (void)tblgen_kernel_func_name; auto tblgen_kernel_module_name = getProperties().kernel_module_name; (void)tblgen_kernel_module_name; auto tblgen_origin = getProperties().origin; (void)tblgen_origin; if (!tblgen_origin) return emitOpError("requires attribute 'origin'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_origin, "origin"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps8(*this, tblgen_kernel_func_name, "kernel_func_name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps8(*this, tblgen_kernel_module_name, "kernel_module_name"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps8(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps9(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); if (valueGroup2.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup2.size(); } for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps10(*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_OpenACCOps9(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ComputeRegionOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ComputeRegionOp::setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); if (!dict) { emitError() << "expected DictionaryAttr to set properties"; return ::mlir::failure(); } // keep track of used keys in the input dictionary to be able to error out // if there are some unknown ones. ::mlir::DenseSet<::mlir::StringAttr> usedKeys; ::mlir::MLIRContext *ctx = dict.getContext(); (void)ctx; { auto &propStorage = prop.origin; auto originAttrName = ::mlir::StringAttr::get(ctx, "origin"); auto attr = dict.get(originAttrName); usedKeys.insert(originAttrName); if (attr || /*isRequired=*/true) { if (!attr) { emitError() << "expected key entry for origin in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `origin` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kernel_func_name; auto kernel_func_nameAttrName = ::mlir::StringAttr::get(ctx, "kernel_func_name"); auto attr = dict.get(kernel_func_nameAttrName); usedKeys.insert(kernel_func_nameAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for kernel_func_name in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kernel_func_name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.kernel_module_name; auto kernel_module_nameAttrName = ::mlir::StringAttr::get(ctx, "kernel_module_name"); auto attr = dict.get(kernel_module_nameAttrName); usedKeys.insert(kernel_module_nameAttrName); if (attr || /*isRequired=*/false) { if (!attr) { emitError() << "expected key entry for kernel_module_name in DictionaryAttr to set " "Properties."; return ::mlir::failure(); } auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `kernel_module_name` in property conversion: " << attr; return ::mlir::failure(); } } } for (::mlir::NamedAttribute attr : dict) { if (!usedKeys.contains(attr.getName())) return emitError() << "unknown key '" << attr.getName() << "' when parsing properties dictionary"; } return ::mlir::success(); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::ComputeRegionOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::ComputeRegionOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::CopyinOp definitions //===----------------------------------------------------------------------===// namespace detail { CopyinOpGenericAdaptorBase::CopyinOpGenericAdaptorBase(CopyinOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair CopyinOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type CopyinOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > CopyinOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > CopyinOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr CopyinOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause CopyinOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr CopyinOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool CopyinOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr CopyinOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool CopyinOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr CopyinOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier CopyinOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > CopyinOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > CopyinOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail CopyinOpAdaptor::CopyinOpAdaptor(CopyinOp op) : CopyinOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CopyinOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.copyin' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.copyin' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.copyin' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.copyin' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.copyin' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.copyin' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.copyin' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.copyin' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.copyin' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.copyin' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair CopyinOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange CopyinOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange CopyinOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange CopyinOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult CopyinOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute CopyinOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code CopyinOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional CopyinOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void CopyinOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void CopyinOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult CopyinOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CopyinOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void CopyinOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type CopyinOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > CopyinOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > CopyinOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause CopyinOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool CopyinOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool CopyinOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier CopyinOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > CopyinOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > CopyinOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void CopyinOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void CopyinOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CopyinOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void CopyinOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void CopyinOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CopyinOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void CopyinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } CopyinOp CopyinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyinOp CopyinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void CopyinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } CopyinOp CopyinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyinOp CopyinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void CopyinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } CopyinOp CopyinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyinOp CopyinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void CopyinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } CopyinOp CopyinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyinOp CopyinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void CopyinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } CopyinOp CopyinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyinOp CopyinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void CopyinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CopyinOp CopyinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyinOp CopyinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void CopyinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } CopyinOp CopyinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyinOp CopyinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void CopyinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CopyinOp CopyinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyinOp CopyinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void CopyinOp::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."); } } CopyinOp CopyinOp::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__; } CopyinOp CopyinOp::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 CopyinOp::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); } CopyinOp CopyinOp::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__; } CopyinOp CopyinOp::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 CopyinOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_copyin); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult CopyinOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CopyinOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult CopyinOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void CopyinOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_copyin))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::CopyinOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::CopyinOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::CopyoutOp definitions //===----------------------------------------------------------------------===// namespace detail { CopyoutOpGenericAdaptorBase::CopyoutOpGenericAdaptorBase(CopyoutOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair CopyoutOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type CopyoutOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > CopyoutOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > CopyoutOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr CopyoutOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause CopyoutOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr CopyoutOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool CopyoutOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr CopyoutOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool CopyoutOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr CopyoutOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier CopyoutOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > CopyoutOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } } // namespace detail CopyoutOpAdaptor::CopyoutOpAdaptor(CopyoutOp op) : CopyoutOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CopyoutOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.copyout' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.copyout' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.copyout' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.copyout' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.copyout' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.copyout' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.copyout' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.copyout' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.copyout' op attribute 'name' failed to satisfy constraint: string attribute"); return ::mlir::success(); } std::pair CopyoutOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange CopyoutOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange CopyoutOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult CopyoutOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute CopyoutOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code CopyoutOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional CopyoutOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void CopyoutOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void CopyoutOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult CopyoutOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CopyoutOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void CopyoutOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type CopyoutOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > CopyoutOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > CopyoutOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause CopyoutOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool CopyoutOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool CopyoutOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier CopyoutOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > CopyoutOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } void CopyoutOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void CopyoutOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CopyoutOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void CopyoutOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void CopyoutOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CopyoutOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void CopyoutOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, accVar, var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr); } CopyoutOp CopyoutOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyoutOp CopyoutOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void CopyoutOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, accVar, var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name)); } CopyoutOp CopyoutOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyoutOp CopyoutOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void CopyoutOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { build(odsBuilder, odsState, accVar, var, varType, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } CopyoutOp CopyoutOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyoutOp CopyoutOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void CopyoutOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::Value var, ::mlir::TypeAttr varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(var); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } } CopyoutOp CopyoutOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::Value var, ::mlir::TypeAttr varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyoutOp CopyoutOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::Value var, ::mlir::TypeAttr varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void CopyoutOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::Value var, ::mlir::TypeAttr varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(var); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CopyoutOp CopyoutOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::Value var, ::mlir::TypeAttr varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyoutOp CopyoutOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::Value var, ::mlir::TypeAttr varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void CopyoutOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(var); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } } CopyoutOp CopyoutOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyoutOp CopyoutOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void CopyoutOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(var); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } CopyoutOp CopyoutOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CopyoutOp CopyoutOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void CopyoutOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } CopyoutOp CopyoutOp::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__; } CopyoutOp CopyoutOp::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 CopyoutOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } CopyoutOp CopyoutOp::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__; } CopyoutOp CopyoutOp::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 CopyoutOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_copyout); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult CopyoutOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CopyoutOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult CopyoutOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand accVarRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> accVarOperands(&accVarRawOperand, 1); ::llvm::SMLoc accVarOperandsLoc; (void)accVarOperandsLoc; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; { accVarOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseAccVar(parser, accVarRawOperand, accVarRawType); if (odsResult) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalKeyword("bounds"))) { if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalKeyword("async"))) { { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } if (parser.parseKeyword("to")) return ::mlir::failure(); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } { 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(); } ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); if (parser.resolveOperands(accVarOperands, accVarTypes, accVarOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void CopyoutOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printAccVar(_odsPrinter, *this, getAccVar(), getAccVar().getType()); if (!getBounds().empty()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (((!getAsyncOperands().empty()) || (!getAsyncOperands().empty()) || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr()))) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("varType"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_copyout))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::CopyoutOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::CopyoutOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::CreateOp definitions //===----------------------------------------------------------------------===// namespace detail { CreateOpGenericAdaptorBase::CreateOpGenericAdaptorBase(CreateOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair CreateOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type CreateOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > CreateOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > CreateOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr CreateOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause CreateOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr CreateOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool CreateOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr CreateOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool CreateOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr CreateOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier CreateOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > CreateOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > CreateOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail CreateOpAdaptor::CreateOpAdaptor(CreateOp op) : CreateOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult CreateOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.create' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.create' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.create' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.create' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.create' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.create' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.create' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.create' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.create' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.create' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair CreateOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange CreateOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange CreateOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange CreateOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult CreateOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute CreateOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code CreateOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional CreateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void CreateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void CreateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult CreateOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult CreateOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void CreateOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type CreateOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > CreateOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > CreateOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause CreateOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool CreateOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool CreateOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier CreateOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > CreateOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > CreateOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void CreateOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void CreateOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CreateOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void CreateOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void CreateOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void CreateOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void CreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } CreateOp CreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CreateOp CreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void CreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } CreateOp CreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CreateOp CreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void CreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } CreateOp CreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CreateOp CreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void CreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } CreateOp CreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CreateOp CreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void CreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } CreateOp CreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CreateOp CreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void CreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CreateOp CreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CreateOp CreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void CreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } CreateOp CreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CreateOp CreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void CreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } CreateOp CreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } CreateOp CreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void CreateOp::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."); } } CreateOp CreateOp::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__; } CreateOp CreateOp::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 CreateOp::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); } CreateOp CreateOp::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__; } CreateOp CreateOp::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 CreateOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_create); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult CreateOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult CreateOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult CreateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void CreateOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_create))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::CreateOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::CreateOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::DataBoundsOp definitions //===----------------------------------------------------------------------===// namespace detail { DataBoundsOpGenericAdaptorBase::DataBoundsOpGenericAdaptorBase(DataBoundsOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair DataBoundsOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::BoolAttr DataBoundsOpGenericAdaptorBase::getStrideInBytesAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().strideInBytes); return attr; } bool DataBoundsOpGenericAdaptorBase::getStrideInBytes() { auto attr = getStrideInBytesAttr(); return attr.getValue(); } } // namespace detail DataBoundsOpAdaptor::DataBoundsOpAdaptor(DataBoundsOp op) : DataBoundsOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DataBoundsOpAdaptor::verify(::mlir::Location loc) { auto tblgen_strideInBytes = getProperties().strideInBytes; (void)tblgen_strideInBytes; if (tblgen_strideInBytes && !((::llvm::isa<::mlir::BoolAttr>(tblgen_strideInBytes)))) return emitError(loc, "'acc.bounds' op attribute 'strideInBytes' failed to satisfy constraint: bool attribute"); return ::mlir::success(); } std::pair DataBoundsOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange DataBoundsOp::getLowerboundMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DataBoundsOp::getUpperboundMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DataBoundsOp::getExtentMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DataBoundsOp::getStrideMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DataBoundsOp::getStartIdxMutable() { auto range = getODSOperandIndexAndLength(4); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(4u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult DataBoundsOp::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.strideInBytes; auto attr = dict.get("strideInBytes"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `strideInBytes` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute DataBoundsOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.strideInBytes; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("strideInBytes", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DataBoundsOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.strideInBytes.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional DataBoundsOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "strideInBytes") return prop.strideInBytes; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void DataBoundsOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "strideInBytes") { prop.strideInBytes = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void DataBoundsOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.strideInBytes) attrs.append("strideInBytes", prop.strideInBytes); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult DataBoundsOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getStrideInBytesAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "strideInBytes", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult DataBoundsOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.strideInBytes))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void DataBoundsOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.strideInBytes); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } bool DataBoundsOp::getStrideInBytes() { auto attr = getStrideInBytesAttr(); return attr.getValue(); } void DataBoundsOp::setStrideInBytes(bool attrValue) { getProperties().strideInBytes = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void DataBoundsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value extent) { build(odsBuilder, odsState, ::mlir::acc::DataBoundsType::get(odsBuilder.getContext()), /*lowerbound=*/{}, /*upperbound=*/{}, extent, /*stride=*/{}, /*strideInBytes=*/odsBuilder.getBoolAttr(false), /*startIdx=*/{}); } DataBoundsOp DataBoundsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value extent) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(extent)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DataBoundsOp DataBoundsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value extent) { return create(builder, builder.getLoc(), std::forward(extent)); } void DataBoundsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lowerbound, ::mlir::Value upperbound) { build(odsBuilder, odsState, ::mlir::acc::DataBoundsType::get(odsBuilder.getContext()), lowerbound, upperbound, /*extent=*/{}, /*stride=*/{}, /*strideInBytes=*/odsBuilder.getBoolAttr(false), /*startIdx=*/{}); } DataBoundsOp DataBoundsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value lowerbound, ::mlir::Value upperbound) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lowerbound), std::forward(upperbound)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DataBoundsOp DataBoundsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value lowerbound, ::mlir::Value upperbound) { return create(builder, builder.getLoc(), std::forward(lowerbound), std::forward(upperbound)); } void DataBoundsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, ::mlir::BoolAttr strideInBytes, /*optional*/::mlir::Value startIdx) { if (lowerbound) odsState.addOperands(lowerbound); if (upperbound) odsState.addOperands(upperbound); if (extent) odsState.addOperands(extent); if (stride) odsState.addOperands(stride); if (startIdx) odsState.addOperands(startIdx); ::llvm::copy(::llvm::ArrayRef({(lowerbound ? 1 : 0), (upperbound ? 1 : 0), (extent ? 1 : 0), (stride ? 1 : 0), (startIdx ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (strideInBytes) { odsState.getOrAddProperties().strideInBytes = strideInBytes; } odsState.addTypes(result); } DataBoundsOp DataBoundsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, ::mlir::BoolAttr strideInBytes, /*optional*/::mlir::Value startIdx) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lowerbound), std::forward(upperbound), std::forward(extent), std::forward(stride), std::forward(strideInBytes), std::forward(startIdx)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DataBoundsOp DataBoundsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, ::mlir::BoolAttr strideInBytes, /*optional*/::mlir::Value startIdx) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lowerbound), std::forward(upperbound), std::forward(extent), std::forward(stride), std::forward(strideInBytes), std::forward(startIdx)); } void DataBoundsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, ::mlir::BoolAttr strideInBytes, /*optional*/::mlir::Value startIdx) { if (lowerbound) odsState.addOperands(lowerbound); if (upperbound) odsState.addOperands(upperbound); if (extent) odsState.addOperands(extent); if (stride) odsState.addOperands(stride); if (startIdx) odsState.addOperands(startIdx); ::llvm::copy(::llvm::ArrayRef({(lowerbound ? 1 : 0), (upperbound ? 1 : 0), (extent ? 1 : 0), (stride ? 1 : 0), (startIdx ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (strideInBytes) { odsState.getOrAddProperties().strideInBytes = strideInBytes; } ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DataBoundsOp::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); } DataBoundsOp DataBoundsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, ::mlir::BoolAttr strideInBytes, /*optional*/::mlir::Value startIdx) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lowerbound), std::forward(upperbound), std::forward(extent), std::forward(stride), std::forward(strideInBytes), std::forward(startIdx)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DataBoundsOp DataBoundsOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, ::mlir::BoolAttr strideInBytes, /*optional*/::mlir::Value startIdx) { return create(builder, builder.getLoc(), std::forward(lowerbound), std::forward(upperbound), std::forward(extent), std::forward(stride), std::forward(strideInBytes), std::forward(startIdx)); } void DataBoundsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, ::mlir::BoolAttr strideInBytes, /*optional*/::mlir::Value startIdx) { if (lowerbound) odsState.addOperands(lowerbound); if (upperbound) odsState.addOperands(upperbound); if (extent) odsState.addOperands(extent); if (stride) odsState.addOperands(stride); if (startIdx) odsState.addOperands(startIdx); ::llvm::copy(::llvm::ArrayRef({(lowerbound ? 1 : 0), (upperbound ? 1 : 0), (extent ? 1 : 0), (stride ? 1 : 0), (startIdx ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (strideInBytes) { odsState.getOrAddProperties().strideInBytes = strideInBytes; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DataBoundsOp DataBoundsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, ::mlir::BoolAttr strideInBytes, /*optional*/::mlir::Value startIdx) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lowerbound), std::forward(upperbound), std::forward(extent), std::forward(stride), std::forward(strideInBytes), std::forward(startIdx)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DataBoundsOp DataBoundsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, ::mlir::BoolAttr strideInBytes, /*optional*/::mlir::Value startIdx) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lowerbound), std::forward(upperbound), std::forward(extent), std::forward(stride), std::forward(strideInBytes), std::forward(startIdx)); } void DataBoundsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, bool strideInBytes, /*optional*/::mlir::Value startIdx) { if (lowerbound) odsState.addOperands(lowerbound); if (upperbound) odsState.addOperands(upperbound); if (extent) odsState.addOperands(extent); if (stride) odsState.addOperands(stride); if (startIdx) odsState.addOperands(startIdx); ::llvm::copy(::llvm::ArrayRef({(lowerbound ? 1 : 0), (upperbound ? 1 : 0), (extent ? 1 : 0), (stride ? 1 : 0), (startIdx ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().strideInBytes = odsBuilder.getBoolAttr(strideInBytes); odsState.addTypes(result); } DataBoundsOp DataBoundsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, bool strideInBytes, /*optional*/::mlir::Value startIdx) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(lowerbound), std::forward(upperbound), std::forward(extent), std::forward(stride), std::forward(strideInBytes), std::forward(startIdx)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DataBoundsOp DataBoundsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, bool strideInBytes, /*optional*/::mlir::Value startIdx) { return create(builder, builder.getLoc(), std::forward(result), std::forward(lowerbound), std::forward(upperbound), std::forward(extent), std::forward(stride), std::forward(strideInBytes), std::forward(startIdx)); } void DataBoundsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, bool strideInBytes, /*optional*/::mlir::Value startIdx) { if (lowerbound) odsState.addOperands(lowerbound); if (upperbound) odsState.addOperands(upperbound); if (extent) odsState.addOperands(extent); if (stride) odsState.addOperands(stride); if (startIdx) odsState.addOperands(startIdx); ::llvm::copy(::llvm::ArrayRef({(lowerbound ? 1 : 0), (upperbound ? 1 : 0), (extent ? 1 : 0), (stride ? 1 : 0), (startIdx ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().strideInBytes = odsBuilder.getBoolAttr(strideInBytes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DataBoundsOp::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); } DataBoundsOp DataBoundsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, bool strideInBytes, /*optional*/::mlir::Value startIdx) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lowerbound), std::forward(upperbound), std::forward(extent), std::forward(stride), std::forward(strideInBytes), std::forward(startIdx)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DataBoundsOp DataBoundsOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, bool strideInBytes, /*optional*/::mlir::Value startIdx) { return create(builder, builder.getLoc(), std::forward(lowerbound), std::forward(upperbound), std::forward(extent), std::forward(stride), std::forward(strideInBytes), std::forward(startIdx)); } void DataBoundsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, bool strideInBytes, /*optional*/::mlir::Value startIdx) { if (lowerbound) odsState.addOperands(lowerbound); if (upperbound) odsState.addOperands(upperbound); if (extent) odsState.addOperands(extent); if (stride) odsState.addOperands(stride); if (startIdx) odsState.addOperands(startIdx); ::llvm::copy(::llvm::ArrayRef({(lowerbound ? 1 : 0), (upperbound ? 1 : 0), (extent ? 1 : 0), (stride ? 1 : 0), (startIdx ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().strideInBytes = odsBuilder.getBoolAttr(strideInBytes); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DataBoundsOp DataBoundsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, bool strideInBytes, /*optional*/::mlir::Value startIdx) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(lowerbound), std::forward(upperbound), std::forward(extent), std::forward(stride), std::forward(strideInBytes), std::forward(startIdx)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DataBoundsOp DataBoundsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value lowerbound, /*optional*/::mlir::Value upperbound, /*optional*/::mlir::Value extent, /*optional*/::mlir::Value stride, bool strideInBytes, /*optional*/::mlir::Value startIdx) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(lowerbound), std::forward(upperbound), std::forward(extent), std::forward(stride), std::forward(strideInBytes), std::forward(startIdx)); } void DataBoundsOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } DataBoundsOp DataBoundsOp::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__; } DataBoundsOp DataBoundsOp::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 DataBoundsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { 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(DataBoundsOp::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)."); } } DataBoundsOp DataBoundsOp::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__; } DataBoundsOp DataBoundsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void DataBoundsOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DataBoundsOp DataBoundsOp::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__; } DataBoundsOp DataBoundsOp::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 DataBoundsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DataBoundsOp::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)."); } } DataBoundsOp DataBoundsOp::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__; } DataBoundsOp DataBoundsOp::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 DataBoundsOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.strideInBytes) properties.strideInBytes = odsBuilder.getBoolAttr(false); } ::llvm::LogicalResult DataBoundsOp::verifyInvariantsImpl() { auto tblgen_strideInBytes = getProperties().strideInBytes; (void)tblgen_strideInBytes; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_strideInBytes, "strideInBytes"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); if (valueGroup0.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup0.size(); } for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); if (valueGroup2.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup2.size(); } for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); if (valueGroup3.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup3.size(); } for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); if (valueGroup4.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup4.size(); } for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*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_OpenACCOps12(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DataBoundsOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult DataBoundsOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getType<::mlir::acc::DataBoundsType>(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult DataBoundsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> lowerboundOperands; ::llvm::SMLoc lowerboundOperandsLoc; (void)lowerboundOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> lowerboundTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> upperboundOperands; ::llvm::SMLoc upperboundOperandsLoc; (void)upperboundOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> upperboundTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> extentOperands; ::llvm::SMLoc extentOperandsLoc; (void)extentOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> extentTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> strideOperands; ::llvm::SMLoc strideOperandsLoc; (void)strideOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> strideTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> startIdxOperands; ::llvm::SMLoc startIdxOperandsLoc; (void)startIdxOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> startIdxTypes; bool lowerboundClause = false; bool upperboundClause = false; bool extentClause = false; bool strideClause = false; bool startIdxClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("lowerbound"))) { if (lowerboundClause) { return parser.emitError(parser.getNameLoc()) << "`lowerbound` clause can appear at most once in the expansion of the " "oilist directive"; } lowerboundClause = true; if (parser.parseLParen()) return ::mlir::failure(); { lowerboundOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); lowerboundOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); lowerboundTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("upperbound"))) { if (upperboundClause) { return parser.emitError(parser.getNameLoc()) << "`upperbound` clause can appear at most once in the expansion of the " "oilist directive"; } upperboundClause = true; if (parser.parseLParen()) return ::mlir::failure(); { upperboundOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); upperboundOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); upperboundTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("extent"))) { if (extentClause) { return parser.emitError(parser.getNameLoc()) << "`extent` clause can appear at most once in the expansion of the " "oilist directive"; } extentClause = true; if (parser.parseLParen()) return ::mlir::failure(); { extentOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); extentOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); extentTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("stride"))) { if (strideClause) { return parser.emitError(parser.getNameLoc()) << "`stride` clause can appear at most once in the expansion of the " "oilist directive"; } strideClause = true; if (parser.parseLParen()) return ::mlir::failure(); { strideOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); strideOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); strideTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("startIdx"))) { if (startIdxClause) { return parser.emitError(parser.getNameLoc()) << "`startIdx` clause can appear at most once in the expansion of the " "oilist directive"; } startIdxClause = true; if (parser.parseLParen()) return ::mlir::failure(); { startIdxOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); startIdxOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); startIdxTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } { 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(); } ::llvm::copy(::llvm::ArrayRef({static_cast(lowerboundOperands.size()), static_cast(upperboundOperands.size()), static_cast(extentOperands.size()), static_cast(strideOperands.size()), static_cast(startIdxOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(odsBuildableType0); if (!lowerboundOperands.empty()) { if (parser.resolveOperands(lowerboundOperands, lowerboundTypes, lowerboundOperandsLoc, result.operands)) return ::mlir::failure(); } if (!upperboundOperands.empty()) { if (parser.resolveOperands(upperboundOperands, upperboundTypes, upperboundOperandsLoc, result.operands)) return ::mlir::failure(); } if (!extentOperands.empty()) { if (parser.resolveOperands(extentOperands, extentTypes, extentOperandsLoc, result.operands)) return ::mlir::failure(); } if (!strideOperands.empty()) { if (parser.resolveOperands(strideOperands, strideTypes, strideOperandsLoc, result.operands)) return ::mlir::failure(); } if (!startIdxOperands.empty()) { if (parser.resolveOperands(startIdxOperands, startIdxTypes, startIdxOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void DataBoundsOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getLowerbound()) { _odsPrinter << ' ' << "lowerbound"; _odsPrinter << "("; if (::mlir::Value value = getLowerbound()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getLowerbound() ? ::llvm::ArrayRef<::mlir::Type>(getLowerbound().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getUpperbound()) { _odsPrinter << ' ' << "upperbound"; _odsPrinter << "("; if (::mlir::Value value = getUpperbound()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getUpperbound() ? ::llvm::ArrayRef<::mlir::Type>(getUpperbound().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getExtent()) { _odsPrinter << ' ' << "extent"; _odsPrinter << "("; if (::mlir::Value value = getExtent()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getExtent() ? ::llvm::ArrayRef<::mlir::Type>(getExtent().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getStride()) { _odsPrinter << ' ' << "stride"; _odsPrinter << "("; if (::mlir::Value value = getStride()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getStride() ? ::llvm::ArrayRef<::mlir::Type>(getStride().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getStartIdx()) { _odsPrinter << ' ' << "startIdx"; _odsPrinter << "("; if (::mlir::Value value = getStartIdx()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getStartIdx() ? ::llvm::ArrayRef<::mlir::Type>(getStartIdx().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStrideInBytesAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("strideInBytes"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } void DataBoundsOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::DataBoundsOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::DataBoundsOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::DataOp definitions //===----------------------------------------------------------------------===// namespace detail { DataOpGenericAdaptorBase::DataOpGenericAdaptorBase(DataOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair DataOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::std::optional< ::mlir::ArrayAttr > DataOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DataOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> DataOpGenericAdaptorBase::getWaitOperandsSegments() { auto attr = getWaitOperandsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DataOpGenericAdaptorBase::getWaitOperandsDeviceType() { auto attr = getWaitOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DataOpGenericAdaptorBase::getHasWaitDevnum() { auto attr = getHasWaitDevnumAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DataOpGenericAdaptorBase::getWaitOnly() { auto attr = getWaitOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::mlir::acc::ClauseDefaultValue> DataOpGenericAdaptorBase::getDefaultAttr() { auto attr = getDefaultAttrAttr(); return attr ? ::std::optional<::mlir::acc::ClauseDefaultValue>(attr.getValue()) : (::std::nullopt); } } // namespace detail DataOpAdaptor::DataOpAdaptor(DataOp op) : DataOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DataOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_defaultAttr = getProperties().defaultAttr; (void)tblgen_defaultAttr; auto tblgen_hasWaitDevnum = getProperties().hasWaitDevnum; (void)tblgen_hasWaitDevnum; auto tblgen_waitOnly = getProperties().waitOnly; (void)tblgen_waitOnly; auto tblgen_waitOperandsDeviceType = getProperties().waitOperandsDeviceType; (void)tblgen_waitOperandsDeviceType; auto tblgen_waitOperandsSegments = getProperties().waitOperandsSegments; (void)tblgen_waitOperandsSegments; if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.data' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.data' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_waitOperandsSegments && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_waitOperandsSegments)))) return emitError(loc, "'acc.data' op attribute 'waitOperandsSegments' failed to satisfy constraint: i32 dense array attribute"); if (tblgen_waitOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_waitOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_waitOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.data' op attribute 'waitOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_hasWaitDevnum && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_hasWaitDevnum))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_hasWaitDevnum), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::BoolAttr>(attr))); })))) return emitError(loc, "'acc.data' op attribute 'hasWaitDevnum' failed to satisfy constraint: 1-bit boolean array attribute"); if (tblgen_waitOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_waitOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_waitOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.data' op attribute 'waitOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_defaultAttr && !((::llvm::isa<::mlir::acc::ClauseDefaultValueAttr>(tblgen_defaultAttr)))) return emitError(loc, "'acc.data' op attribute 'defaultAttr' failed to satisfy constraint: DefaultValue Clause"); return ::mlir::success(); } std::pair DataOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange DataOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DataOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DataOp::getWaitOperandsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DataOp::getDataClauseOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult DataOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.defaultAttr; auto attr = dict.get("defaultAttr"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `defaultAttr` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.hasWaitDevnum; auto attr = dict.get("hasWaitDevnum"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `hasWaitDevnum` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOnly; auto attr = dict.get("waitOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOperandsDeviceType; auto attr = dict.get("waitOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOperandsSegments; auto attr = dict.get("waitOperandsSegments"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOperandsSegments` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute DataOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.defaultAttr; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("defaultAttr", propStorage)); } { const auto &propStorage = prop.hasWaitDevnum; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("hasWaitDevnum", propStorage)); } { const auto &propStorage = prop.waitOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOnly", propStorage)); } { const auto &propStorage = prop.waitOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.waitOperandsSegments; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOperandsSegments", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DataOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.defaultAttr.getAsOpaquePointer()), llvm::hash_value(prop.hasWaitDevnum.getAsOpaquePointer()), llvm::hash_value(prop.waitOnly.getAsOpaquePointer()), llvm::hash_value(prop.waitOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.waitOperandsSegments.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional DataOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "defaultAttr") return prop.defaultAttr; if (name == "hasWaitDevnum") return prop.hasWaitDevnum; if (name == "waitOnly") return prop.waitOnly; if (name == "waitOperandsDeviceType") return prop.waitOperandsDeviceType; if (name == "waitOperandsSegments") return prop.waitOperandsSegments; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void DataOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "defaultAttr") { prop.defaultAttr = ::llvm::dyn_cast_or_null>(value); return; } if (name == "hasWaitDevnum") { prop.hasWaitDevnum = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOnly") { prop.waitOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOperandsDeviceType") { prop.waitOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOperandsSegments") { prop.waitOperandsSegments = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void DataOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.defaultAttr) attrs.append("defaultAttr", prop.defaultAttr); if (prop.hasWaitDevnum) attrs.append("hasWaitDevnum", prop.hasWaitDevnum); if (prop.waitOnly) attrs.append("waitOnly", prop.waitOnly); if (prop.waitOperandsDeviceType) attrs.append("waitOperandsDeviceType", prop.waitOperandsDeviceType); if (prop.waitOperandsSegments) attrs.append("waitOperandsSegments", prop.waitOperandsSegments); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult DataOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDefaultAttrAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps11(attr, "defaultAttr", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getHasWaitDevnumAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps10(attr, "hasWaitDevnum", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "waitOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "waitOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOperandsSegmentsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(attr, "waitOperandsSegments", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult DataOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.defaultAttr))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.hasWaitDevnum))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.waitOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.waitOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.waitOperandsSegments))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void DataOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.defaultAttr); writer.writeOptionalAttribute(prop.hasWaitDevnum); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.waitOnly); writer.writeOptionalAttribute(prop.waitOperandsDeviceType); writer.writeOptionalAttribute(prop.waitOperandsSegments); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::std::optional< ::mlir::ArrayAttr > DataOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DataOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> DataOp::getWaitOperandsSegments() { auto attr = getWaitOperandsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DataOp::getWaitOperandsDeviceType() { auto attr = getWaitOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DataOp::getHasWaitDevnum() { auto attr = getHasWaitDevnumAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DataOp::getWaitOnly() { auto attr = getWaitOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::mlir::acc::ClauseDefaultValue> DataOp::getDefaultAttr() { auto attr = getDefaultAttrAttr(); return attr ? ::std::optional<::mlir::acc::ClauseDefaultValue>(attr.getValue()) : (::std::nullopt); } void DataOp::setWaitOperandsSegments(::std::optional<::llvm::ArrayRef> attrValue) { auto &odsProp = getProperties().waitOperandsSegments; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(*attrValue); else odsProp = nullptr; } void DataOp::setDefaultAttr(::std::optional<::mlir::acc::ClauseDefaultValue> attrValue) { auto &odsProp = getProperties().defaultAttr; if (attrValue) odsProp = ::mlir::acc::ClauseDefaultValueAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void DataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr) { if (ifCond) odsState.addOperands(ifCond); odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), static_cast(asyncOperands.size()), static_cast(waitOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (defaultAttr) { odsState.getOrAddProperties().defaultAttr = defaultAttr; } (void)odsState.addRegion(); } DataOp DataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ifCond), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(dataClauseOperands), std::forward(defaultAttr)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DataOp DataOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr) { return create(builder, builder.getLoc(), std::forward(ifCond), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(dataClauseOperands), std::forward(defaultAttr)); } void DataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr) { if (ifCond) odsState.addOperands(ifCond); odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), static_cast(asyncOperands.size()), static_cast(waitOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (defaultAttr) { odsState.getOrAddProperties().defaultAttr = defaultAttr; } (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } DataOp DataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ifCond), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(dataClauseOperands), std::forward(defaultAttr)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DataOp DataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ifCond), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(dataClauseOperands), std::forward(defaultAttr)); } void DataOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } DataOp DataOp::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__; } DataOp DataOp::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 DataOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DataOp DataOp::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__; } DataOp DataOp::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 DataOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_defaultAttr = getProperties().defaultAttr; (void)tblgen_defaultAttr; auto tblgen_hasWaitDevnum = getProperties().hasWaitDevnum; (void)tblgen_hasWaitDevnum; auto tblgen_waitOnly = getProperties().waitOnly; (void)tblgen_waitOnly; auto tblgen_waitOperandsDeviceType = getProperties().waitOperandsDeviceType; (void)tblgen_waitOperandsDeviceType; auto tblgen_waitOperandsSegments = getProperties().waitOperandsSegments; (void)tblgen_waitOperandsSegments; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(*this, tblgen_waitOperandsSegments, "waitOperandsSegments"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_waitOperandsDeviceType, "waitOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps10(*this, tblgen_hasWaitDevnum, "hasWaitDevnum"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_waitOnly, "waitOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps11(*this, tblgen_defaultAttr, "defaultAttr"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); if (valueGroup0.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup0.size(); } for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult DataOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult DataOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dataClauseOperandsOperands; ::llvm::SMLoc dataClauseOperandsOperandsLoc; (void)dataClauseOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> dataClauseOperandsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> waitOperandsOperands; ::llvm::SMLoc waitOperandsOperandsLoc; (void)waitOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> waitOperandsTypes; ::mlir::ArrayAttr waitOperandsDeviceTypeAttr; ::mlir::DenseI32ArrayAttr waitOperandsSegmentsAttr; ::mlir::ArrayAttr hasWaitDevnumAttr; ::mlir::ArrayAttr waitOnlyAttr; std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); bool ifClause = false; bool asyncClause = false; bool dataOperandsClause = false; bool waitClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("dataOperands"))) { if (dataOperandsClause) { return parser.emitError(parser.getNameLoc()) << "`dataOperands` clause can appear at most once in the expansion of the " "oilist directive"; } dataOperandsClause = true; if (parser.parseLParen()) return ::mlir::failure(); dataClauseOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(dataClauseOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(dataClauseOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("wait"))) { if (waitClause) { return parser.emitError(parser.getNameLoc()) << "`wait` clause can appear at most once in the expansion of the " "oilist directive"; } waitClause = true; { waitOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseWaitClause(parser, waitOperandsOperands, waitOperandsTypes, waitOperandsDeviceTypeAttr, waitOperandsSegmentsAttr, hasWaitDevnumAttr, waitOnlyAttr); if (odsResult) return ::mlir::failure(); if (waitOperandsDeviceTypeAttr) result.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceTypeAttr; if (waitOperandsSegmentsAttr) result.getOrAddProperties().waitOperandsSegments = waitOperandsSegmentsAttr; if (hasWaitDevnumAttr) result.getOrAddProperties().hasWaitDevnum = hasWaitDevnumAttr; if (waitOnlyAttr) result.getOrAddProperties().waitOnly = waitOnlyAttr; } } else { break; } } if (parser.parseRegion(*regionRegion)) return ::mlir::failure(); { 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(); } result.addRegion(std::move(regionRegion)); ::llvm::copy(::llvm::ArrayRef({static_cast(ifCondOperands.size()), static_cast(asyncOperandsOperands.size()), static_cast(waitOperandsOperands.size()), static_cast(dataClauseOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(waitOperandsOperands, waitOperandsTypes, waitOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(dataClauseOperandsOperands, dataClauseOperandsTypes, dataClauseOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DataOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || getDataClauseOperands().size()) { _odsPrinter << ' ' << "dataOperands"; _odsPrinter << "("; _odsPrinter << getDataClauseOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getDataClauseOperands().getTypes(); _odsPrinter << ")"; } if (false || getWaitOperands().size() || (getWaitOperandsDeviceTypeAttr()) || (getWaitOperandsSegmentsAttr()) || (getHasWaitDevnumAttr()) || (getWaitOnlyAttr())) { _odsPrinter << ' ' << "wait"; printWaitClause(_odsPrinter, *this, getWaitOperands(), getWaitOperands().getTypes(), getWaitOperandsDeviceTypeAttr(), getWaitOperandsSegmentsAttr(), getHasWaitDevnumAttr(), getWaitOnlyAttr()); } _odsPrinter << ' '; _odsPrinter.printRegion(getRegion()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("waitOperandsDeviceType"); elidedAttrs.push_back("waitOperandsSegments"); elidedAttrs.push_back("hasWaitDevnum"); elidedAttrs.push_back("waitOnly"); _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } void DataOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::acc::ConstructResource::get()); effects.emplace_back(::mlir::MemoryEffects::Read::get(), 0, false, ::mlir::acc::CurrentDeviceIdResource::get()); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::DataOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::DataOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::DeclareDeviceResidentOp definitions //===----------------------------------------------------------------------===// namespace detail { DeclareDeviceResidentOpGenericAdaptorBase::DeclareDeviceResidentOpGenericAdaptorBase(DeclareDeviceResidentOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair DeclareDeviceResidentOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type DeclareDeviceResidentOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > DeclareDeviceResidentOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DeclareDeviceResidentOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr DeclareDeviceResidentOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause DeclareDeviceResidentOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr DeclareDeviceResidentOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool DeclareDeviceResidentOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr DeclareDeviceResidentOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool DeclareDeviceResidentOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr DeclareDeviceResidentOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier DeclareDeviceResidentOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > DeclareDeviceResidentOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > DeclareDeviceResidentOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail DeclareDeviceResidentOpAdaptor::DeclareDeviceResidentOpAdaptor(DeclareDeviceResidentOp op) : DeclareDeviceResidentOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DeclareDeviceResidentOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.declare_device_resident' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.declare_device_resident' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.declare_device_resident' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.declare_device_resident' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.declare_device_resident' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.declare_device_resident' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.declare_device_resident' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.declare_device_resident' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.declare_device_resident' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.declare_device_resident' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair DeclareDeviceResidentOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange DeclareDeviceResidentOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DeclareDeviceResidentOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DeclareDeviceResidentOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult DeclareDeviceResidentOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute DeclareDeviceResidentOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DeclareDeviceResidentOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional DeclareDeviceResidentOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void DeclareDeviceResidentOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void DeclareDeviceResidentOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult DeclareDeviceResidentOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult DeclareDeviceResidentOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void DeclareDeviceResidentOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type DeclareDeviceResidentOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > DeclareDeviceResidentOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DeclareDeviceResidentOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause DeclareDeviceResidentOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool DeclareDeviceResidentOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool DeclareDeviceResidentOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier DeclareDeviceResidentOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > DeclareDeviceResidentOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > DeclareDeviceResidentOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void DeclareDeviceResidentOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void DeclareDeviceResidentOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DeclareDeviceResidentOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void DeclareDeviceResidentOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void DeclareDeviceResidentOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DeclareDeviceResidentOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void DeclareDeviceResidentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void DeclareDeviceResidentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void DeclareDeviceResidentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void DeclareDeviceResidentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void DeclareDeviceResidentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void DeclareDeviceResidentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void DeclareDeviceResidentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void DeclareDeviceResidentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareDeviceResidentOp DeclareDeviceResidentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void DeclareDeviceResidentOp::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."); } } DeclareDeviceResidentOp DeclareDeviceResidentOp::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__; } DeclareDeviceResidentOp DeclareDeviceResidentOp::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 DeclareDeviceResidentOp::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); } DeclareDeviceResidentOp DeclareDeviceResidentOp::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__; } DeclareDeviceResidentOp DeclareDeviceResidentOp::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 DeclareDeviceResidentOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_declare_device_resident); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult DeclareDeviceResidentOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DeclareDeviceResidentOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult DeclareDeviceResidentOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DeclareDeviceResidentOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_declare_device_resident))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::DeclareDeviceResidentOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::DeclareDeviceResidentOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::DeclareEnterOp definitions //===----------------------------------------------------------------------===// namespace detail { DeclareEnterOpGenericAdaptorBase::DeclareEnterOpGenericAdaptorBase(DeclareEnterOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair DeclareEnterOpGenericAdaptorBase::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 DeclareEnterOpAdaptor::DeclareEnterOpAdaptor(DeclareEnterOp op) : DeclareEnterOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DeclareEnterOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair DeclareEnterOp::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 DeclareEnterOp::getDataClauseOperandsMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult DeclareEnterOp::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 DeclareEnterOp::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 DeclareEnterOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional DeclareEnterOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void DeclareEnterOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void DeclareEnterOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult DeclareEnterOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void DeclareEnterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type token, ::mlir::ValueRange dataClauseOperands) { odsState.addOperands(dataClauseOperands); odsState.addTypes(token); } DeclareEnterOp DeclareEnterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type token, ::mlir::ValueRange dataClauseOperands) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(token), std::forward(dataClauseOperands)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareEnterOp DeclareEnterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type token, ::mlir::ValueRange dataClauseOperands) { return create(builder, builder.getLoc(), std::forward(token), std::forward(dataClauseOperands)); } void DeclareEnterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DeclareEnterOp DeclareEnterOp::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__; } DeclareEnterOp DeclareEnterOp::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 DeclareEnterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DeclareEnterOp::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)."); } } DeclareEnterOp DeclareEnterOp::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__; } DeclareEnterOp DeclareEnterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void DeclareEnterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DeclareEnterOp DeclareEnterOp::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__; } DeclareEnterOp DeclareEnterOp::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 DeclareEnterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(DeclareEnterOp::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)."); } } DeclareEnterOp DeclareEnterOp::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__; } DeclareEnterOp DeclareEnterOp::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 DeclareEnterOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*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_OpenACCOps14(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DeclareEnterOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult DeclareEnterOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getType<::mlir::acc::DeclareTokenType>(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult DeclareEnterOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dataClauseOperandsOperands; ::llvm::SMLoc dataClauseOperandsOperandsLoc; (void)dataClauseOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> dataClauseOperandsTypes; bool dataOperandsClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("dataOperands"))) { if (dataOperandsClause) { return parser.emitError(parser.getNameLoc()) << "`dataOperands` clause can appear at most once in the expansion of the " "oilist directive"; } dataOperandsClause = true; if (parser.parseLParen()) return ::mlir::failure(); dataClauseOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(dataClauseOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(dataClauseOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } { 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(); } ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DeclareTokenType>(); result.addTypes(odsBuildableType0); if (parser.resolveOperands(dataClauseOperandsOperands, dataClauseOperandsTypes, dataClauseOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DeclareEnterOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getDataClauseOperands().size()) { _odsPrinter << ' ' << "dataOperands"; _odsPrinter << "("; _odsPrinter << getDataClauseOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getDataClauseOperands().getTypes(); _odsPrinter << ")"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } void DeclareEnterOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::acc::ConstructResource::get()); effects.emplace_back(::mlir::MemoryEffects::Read::get(), 0, false, ::mlir::acc::CurrentDeviceIdResource::get()); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::DeclareEnterOp) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::DeclareExitOp definitions //===----------------------------------------------------------------------===// namespace detail { DeclareExitOpGenericAdaptorBase::DeclareExitOpGenericAdaptorBase(DeclareExitOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair DeclareExitOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } } // namespace detail DeclareExitOpAdaptor::DeclareExitOpAdaptor(DeclareExitOp op) : DeclareExitOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DeclareExitOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair DeclareExitOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange DeclareExitOp::getTokenMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DeclareExitOp::getDataClauseOperandsMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult DeclareExitOp::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 setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute DeclareExitOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DeclareExitOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional DeclareExitOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void DeclareExitOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void DeclareExitOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult DeclareExitOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } ::llvm::LogicalResult DeclareExitOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void DeclareExitOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } void DeclareExitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value token, ::mlir::ValueRange dataClauseOperands) { if (token) odsState.addOperands(token); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(token ? 1 : 0), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); } DeclareExitOp DeclareExitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value token, ::mlir::ValueRange dataClauseOperands) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(token), std::forward(dataClauseOperands)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareExitOp DeclareExitOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value token, ::mlir::ValueRange dataClauseOperands) { return create(builder, builder.getLoc(), std::forward(token), std::forward(dataClauseOperands)); } void DeclareExitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value token, ::mlir::ValueRange dataClauseOperands) { if (token) odsState.addOperands(token); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(token ? 1 : 0), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } DeclareExitOp DeclareExitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value token, ::mlir::ValueRange dataClauseOperands) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(token), std::forward(dataClauseOperands)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareExitOp DeclareExitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value token, ::mlir::ValueRange dataClauseOperands) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(token), std::forward(dataClauseOperands)); } void DeclareExitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); 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."); } } DeclareExitOp DeclareExitOp::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__; } DeclareExitOp DeclareExitOp::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 DeclareExitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DeclareExitOp DeclareExitOp::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__; } DeclareExitOp DeclareExitOp::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 DeclareExitOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); if (valueGroup0.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup0.size(); } for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps14(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DeclareExitOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult DeclareExitOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> tokenOperands; ::llvm::SMLoc tokenOperandsLoc; (void)tokenOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dataClauseOperandsOperands; ::llvm::SMLoc dataClauseOperandsOperandsLoc; (void)dataClauseOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> dataClauseOperandsTypes; bool tokenClause = false; bool dataOperandsClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("token"))) { if (tokenClause) { return parser.emitError(parser.getNameLoc()) << "`token` clause can appear at most once in the expansion of the " "oilist directive"; } tokenClause = true; if (parser.parseLParen()) return ::mlir::failure(); { tokenOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); tokenOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("dataOperands"))) { if (dataOperandsClause) { return parser.emitError(parser.getNameLoc()) << "`dataOperands` clause can appear at most once in the expansion of the " "oilist directive"; } dataOperandsClause = true; if (parser.parseLParen()) return ::mlir::failure(); dataClauseOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(dataClauseOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(dataClauseOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } { 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(); } ::llvm::copy(::llvm::ArrayRef({static_cast(tokenOperands.size()), static_cast(dataClauseOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DeclareTokenType>(); if (!tokenOperands.empty()) { if (parser.resolveOperands(tokenOperands, odsBuildableType0, tokenOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(dataClauseOperandsOperands, dataClauseOperandsTypes, dataClauseOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DeclareExitOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getToken()) { _odsPrinter << ' ' << "token"; _odsPrinter << "("; if (::mlir::Value value = getToken()) _odsPrinter << value; _odsPrinter << ")"; } if (false || getDataClauseOperands().size()) { _odsPrinter << ' ' << "dataOperands"; _odsPrinter << "("; _odsPrinter << getDataClauseOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getDataClauseOperands().getTypes(); _odsPrinter << ")"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } void DeclareExitOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::acc::ConstructResource::get()); effects.emplace_back(::mlir::MemoryEffects::Read::get(), 0, false, ::mlir::acc::CurrentDeviceIdResource::get()); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::DeclareExitOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::DeclareExitOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::DeclareLinkOp definitions //===----------------------------------------------------------------------===// namespace detail { DeclareLinkOpGenericAdaptorBase::DeclareLinkOpGenericAdaptorBase(DeclareLinkOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair DeclareLinkOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type DeclareLinkOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > DeclareLinkOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DeclareLinkOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr DeclareLinkOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause DeclareLinkOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr DeclareLinkOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool DeclareLinkOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr DeclareLinkOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool DeclareLinkOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr DeclareLinkOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier DeclareLinkOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > DeclareLinkOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > DeclareLinkOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail DeclareLinkOpAdaptor::DeclareLinkOpAdaptor(DeclareLinkOp op) : DeclareLinkOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DeclareLinkOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.declare_link' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.declare_link' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.declare_link' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.declare_link' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.declare_link' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.declare_link' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.declare_link' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.declare_link' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.declare_link' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.declare_link' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair DeclareLinkOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange DeclareLinkOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DeclareLinkOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DeclareLinkOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult DeclareLinkOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute DeclareLinkOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DeclareLinkOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional DeclareLinkOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void DeclareLinkOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void DeclareLinkOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult DeclareLinkOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult DeclareLinkOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void DeclareLinkOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type DeclareLinkOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > DeclareLinkOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DeclareLinkOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause DeclareLinkOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool DeclareLinkOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool DeclareLinkOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier DeclareLinkOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > DeclareLinkOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > DeclareLinkOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void DeclareLinkOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void DeclareLinkOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DeclareLinkOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void DeclareLinkOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void DeclareLinkOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DeclareLinkOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void DeclareLinkOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } DeclareLinkOp DeclareLinkOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareLinkOp DeclareLinkOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void DeclareLinkOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } DeclareLinkOp DeclareLinkOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareLinkOp DeclareLinkOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void DeclareLinkOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } DeclareLinkOp DeclareLinkOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareLinkOp DeclareLinkOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void DeclareLinkOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } DeclareLinkOp DeclareLinkOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareLinkOp DeclareLinkOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void DeclareLinkOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } DeclareLinkOp DeclareLinkOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareLinkOp DeclareLinkOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void DeclareLinkOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DeclareLinkOp DeclareLinkOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareLinkOp DeclareLinkOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void DeclareLinkOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } DeclareLinkOp DeclareLinkOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareLinkOp DeclareLinkOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void DeclareLinkOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DeclareLinkOp DeclareLinkOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareLinkOp DeclareLinkOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void DeclareLinkOp::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."); } } DeclareLinkOp DeclareLinkOp::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__; } DeclareLinkOp DeclareLinkOp::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 DeclareLinkOp::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); } DeclareLinkOp DeclareLinkOp::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__; } DeclareLinkOp DeclareLinkOp::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 DeclareLinkOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_declare_link); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult DeclareLinkOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DeclareLinkOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult DeclareLinkOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DeclareLinkOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_declare_link))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::DeclareLinkOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::DeclareLinkOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::DeclareOp definitions //===----------------------------------------------------------------------===// namespace detail { DeclareOpGenericAdaptorBase::DeclareOpGenericAdaptorBase(DeclareOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair DeclareOpGenericAdaptorBase::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 DeclareOpAdaptor::DeclareOpAdaptor(DeclareOp op) : DeclareOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DeclareOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair DeclareOp::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 DeclareOp::getDataClauseOperandsMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult DeclareOp::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 DeclareOp::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 DeclareOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional DeclareOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void DeclareOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void DeclareOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult DeclareOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void DeclareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange dataClauseOperands) { odsState.addOperands(dataClauseOperands); (void)odsState.addRegion(); } DeclareOp DeclareOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange dataClauseOperands) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dataClauseOperands)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeclareOp DeclareOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange dataClauseOperands) { return create(builder, builder.getLoc(), std::forward(dataClauseOperands)); } void DeclareOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DeclareOp DeclareOp::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__; } DeclareOp DeclareOp::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 DeclareOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DeclareOp DeclareOp::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__; } DeclareOp DeclareOp::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 DeclareOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult DeclareOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult DeclareOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dataClauseOperandsOperands; ::llvm::SMLoc dataClauseOperandsOperandsLoc; (void)dataClauseOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> dataClauseOperandsTypes; std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); if (parser.parseKeyword("dataOperands")) return ::mlir::failure(); if (parser.parseLParen()) return ::mlir::failure(); dataClauseOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(dataClauseOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(dataClauseOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); if (parser.parseRegion(*regionRegion)) return ::mlir::failure(); { 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(); } result.addRegion(std::move(regionRegion)); if (parser.resolveOperands(dataClauseOperandsOperands, dataClauseOperandsTypes, dataClauseOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DeclareOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' ' << "dataOperands"; _odsPrinter << "("; _odsPrinter << getDataClauseOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getDataClauseOperands().getTypes(); _odsPrinter << ")"; _odsPrinter << ' '; _odsPrinter.printRegion(getRegion()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } void DeclareOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::acc::ConstructResource::get()); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::DeclareOp) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::DeleteOp definitions //===----------------------------------------------------------------------===// namespace detail { DeleteOpGenericAdaptorBase::DeleteOpGenericAdaptorBase(DeleteOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair DeleteOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::std::optional< ::mlir::ArrayAttr > DeleteOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DeleteOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr DeleteOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause DeleteOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr DeleteOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool DeleteOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr DeleteOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool DeleteOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr DeleteOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier DeleteOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > DeleteOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } } // namespace detail DeleteOpAdaptor::DeleteOpAdaptor(DeleteOp op) : DeleteOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DeleteOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.delete' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.delete' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.delete' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.delete' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.delete' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.delete' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.delete' op attribute 'name' failed to satisfy constraint: string attribute"); return ::mlir::success(); } std::pair DeleteOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange DeleteOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DeleteOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult DeleteOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute DeleteOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DeleteOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional DeleteOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "structured") return prop.structured; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void DeleteOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void DeleteOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.structured) attrs.append("structured", prop.structured); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult DeleteOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult DeleteOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void DeleteOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.structured); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::std::optional< ::mlir::ArrayAttr > DeleteOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DeleteOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause DeleteOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool DeleteOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool DeleteOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier DeleteOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > DeleteOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } void DeleteOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DeleteOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void DeleteOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void DeleteOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DeleteOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void DeleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, bool structured, bool implicit, ::mlir::ValueRange bounds) { build(odsBuilder, odsState, accVar, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr); } DeleteOp DeleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeleteOp DeleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void DeleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { build(odsBuilder, odsState, accVar, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name)); } DeleteOp DeleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeleteOp DeleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void DeleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { build(odsBuilder, odsState, accVar, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } DeleteOp DeleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeleteOp DeleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void DeleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } } DeleteOp DeleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeleteOp DeleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void DeleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } DeleteOp DeleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeleteOp DeleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void DeleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } } DeleteOp DeleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeleteOp DeleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void DeleteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } DeleteOp DeleteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DeleteOp DeleteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void DeleteOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } DeleteOp DeleteOp::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__; } DeleteOp DeleteOp::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 DeleteOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DeleteOp DeleteOp::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__; } DeleteOp DeleteOp::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 DeleteOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_delete); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult DeleteOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DeleteOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult DeleteOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand accVarRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> accVarOperands(&accVarRawOperand, 1); ::llvm::SMLoc accVarOperandsLoc; (void)accVarOperandsLoc; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; { accVarOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseAccVar(parser, accVarRawOperand, accVarRawType); if (odsResult) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalKeyword("bounds"))) { if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalKeyword("async"))) { { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } { 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(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); if (parser.resolveOperands(accVarOperands, accVarTypes, accVarOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DeleteOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printAccVar(_odsPrinter, *this, getAccVar(), getAccVar().getType()); if (!getBounds().empty()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (((!getAsyncOperands().empty()) || (!getAsyncOperands().empty()) || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr()))) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_delete))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::DeleteOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::DeleteOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::DetachOp definitions //===----------------------------------------------------------------------===// namespace detail { DetachOpGenericAdaptorBase::DetachOpGenericAdaptorBase(DetachOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair DetachOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::std::optional< ::mlir::ArrayAttr > DetachOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DetachOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr DetachOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause DetachOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr DetachOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool DetachOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr DetachOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool DetachOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr DetachOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier DetachOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > DetachOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } } // namespace detail DetachOpAdaptor::DetachOpAdaptor(DetachOp op) : DetachOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DetachOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.detach' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.detach' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.detach' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.detach' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.detach' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.detach' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.detach' op attribute 'name' failed to satisfy constraint: string attribute"); return ::mlir::success(); } std::pair DetachOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange DetachOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DetachOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult DetachOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute DetachOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DetachOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional DetachOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "structured") return prop.structured; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void DetachOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void DetachOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.structured) attrs.append("structured", prop.structured); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult DetachOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult DetachOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void DetachOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.structured); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::std::optional< ::mlir::ArrayAttr > DetachOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DetachOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause DetachOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool DetachOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool DetachOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier DetachOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > DetachOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } void DetachOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DetachOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void DetachOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void DetachOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DetachOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void DetachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, bool structured, bool implicit, ::mlir::ValueRange bounds) { build(odsBuilder, odsState, accVar, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr); } DetachOp DetachOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DetachOp DetachOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void DetachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { build(odsBuilder, odsState, accVar, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name)); } DetachOp DetachOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DetachOp DetachOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void DetachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { build(odsBuilder, odsState, accVar, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } DetachOp DetachOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DetachOp DetachOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void DetachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } } DetachOp DetachOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DetachOp DetachOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void DetachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } DetachOp DetachOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DetachOp DetachOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void DetachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } } DetachOp DetachOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DetachOp DetachOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void DetachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } DetachOp DetachOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DetachOp DetachOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(accVar), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void DetachOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } DetachOp DetachOp::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__; } DetachOp DetachOp::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 DetachOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } DetachOp DetachOp::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__; } DetachOp DetachOp::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 DetachOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_detach); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult DetachOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DetachOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult DetachOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand accVarRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> accVarOperands(&accVarRawOperand, 1); ::llvm::SMLoc accVarOperandsLoc; (void)accVarOperandsLoc; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; { accVarOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseAccVar(parser, accVarRawOperand, accVarRawType); if (odsResult) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalKeyword("bounds"))) { if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalKeyword("async"))) { { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } { 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(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); if (parser.resolveOperands(accVarOperands, accVarTypes, accVarOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DetachOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printAccVar(_odsPrinter, *this, getAccVar(), getAccVar().getType()); if (!getBounds().empty()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (((!getAsyncOperands().empty()) || (!getAsyncOperands().empty()) || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr()))) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_detach))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::DetachOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::DetachOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::DevicePtrOp definitions //===----------------------------------------------------------------------===// namespace detail { DevicePtrOpGenericAdaptorBase::DevicePtrOpGenericAdaptorBase(DevicePtrOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair DevicePtrOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type DevicePtrOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > DevicePtrOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DevicePtrOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr DevicePtrOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause DevicePtrOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr DevicePtrOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool DevicePtrOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr DevicePtrOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool DevicePtrOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr DevicePtrOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier DevicePtrOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > DevicePtrOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > DevicePtrOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail DevicePtrOpAdaptor::DevicePtrOpAdaptor(DevicePtrOp op) : DevicePtrOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult DevicePtrOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.deviceptr' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.deviceptr' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.deviceptr' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.deviceptr' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.deviceptr' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.deviceptr' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.deviceptr' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.deviceptr' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.deviceptr' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.deviceptr' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair DevicePtrOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange DevicePtrOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DevicePtrOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange DevicePtrOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult DevicePtrOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute DevicePtrOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code DevicePtrOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional DevicePtrOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void DevicePtrOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void DevicePtrOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult DevicePtrOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult DevicePtrOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void DevicePtrOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type DevicePtrOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > DevicePtrOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > DevicePtrOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause DevicePtrOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool DevicePtrOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool DevicePtrOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier DevicePtrOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > DevicePtrOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > DevicePtrOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void DevicePtrOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void DevicePtrOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DevicePtrOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void DevicePtrOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void DevicePtrOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void DevicePtrOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void DevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } DevicePtrOp DevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DevicePtrOp DevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void DevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } DevicePtrOp DevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DevicePtrOp DevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void DevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } DevicePtrOp DevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DevicePtrOp DevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void DevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } DevicePtrOp DevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DevicePtrOp DevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void DevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } DevicePtrOp DevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DevicePtrOp DevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void DevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DevicePtrOp DevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DevicePtrOp DevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void DevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } DevicePtrOp DevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DevicePtrOp DevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void DevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } DevicePtrOp DevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } DevicePtrOp DevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void DevicePtrOp::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."); } } DevicePtrOp DevicePtrOp::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__; } DevicePtrOp DevicePtrOp::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 DevicePtrOp::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); } DevicePtrOp DevicePtrOp::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__; } DevicePtrOp DevicePtrOp::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 DevicePtrOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_deviceptr); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult DevicePtrOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult DevicePtrOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult DevicePtrOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void DevicePtrOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_deviceptr))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::DevicePtrOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::DevicePtrOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::EnterDataOp definitions //===----------------------------------------------------------------------===// namespace detail { EnterDataOpGenericAdaptorBase::EnterDataOpGenericAdaptorBase(EnterDataOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair EnterDataOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::UnitAttr EnterDataOpGenericAdaptorBase::getAsyncAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().async); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool EnterDataOpGenericAdaptorBase::getAsync() { auto attr = getAsyncAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::mlir::UnitAttr EnterDataOpGenericAdaptorBase::getWaitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().wait); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool EnterDataOpGenericAdaptorBase::getWait() { auto attr = getWaitAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail EnterDataOpAdaptor::EnterDataOpAdaptor(EnterDataOp op) : EnterDataOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult EnterDataOpAdaptor::verify(::mlir::Location loc) { auto tblgen_async = getProperties().async; (void)tblgen_async; auto tblgen_wait = getProperties().wait; (void)tblgen_wait; if (tblgen_async && !((::llvm::isa<::mlir::UnitAttr>(tblgen_async)))) return emitError(loc, "'acc.enter_data' op attribute 'async' failed to satisfy constraint: unit attribute"); if (tblgen_wait && !((::llvm::isa<::mlir::UnitAttr>(tblgen_wait)))) return emitError(loc, "'acc.enter_data' op attribute 'wait' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } std::pair EnterDataOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange EnterDataOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange EnterDataOp::getAsyncOperandMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange EnterDataOp::getWaitDevnumMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange EnterDataOp::getWaitOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange EnterDataOp::getDataClauseOperandsMutable() { auto range = getODSOperandIndexAndLength(4); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(4u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult EnterDataOp::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.async; auto attr = dict.get("async"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `async` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.wait; auto attr = dict.get("wait"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `wait` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute EnterDataOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.async; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("async", propStorage)); } { const auto &propStorage = prop.wait; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("wait", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code EnterDataOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.async.getAsOpaquePointer()), llvm::hash_value(prop.wait.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional EnterDataOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "async") return prop.async; if (name == "wait") return prop.wait; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void EnterDataOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "async") { prop.async = ::llvm::dyn_cast_or_null>(value); return; } if (name == "wait") { prop.wait = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void EnterDataOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.async) attrs.append("async", prop.async); if (prop.wait) attrs.append("wait", prop.wait); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult EnterDataOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "async", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "wait", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult EnterDataOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.async))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.wait))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void EnterDataOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.async); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.wait); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } bool EnterDataOp::getAsync() { auto attr = getAsyncAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } bool EnterDataOp::getWait() { auto attr = getWaitAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void EnterDataOp::setAsync(bool attrValue) { auto &odsProp = getProperties().async; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void EnterDataOp::setWait(bool attrValue) { auto &odsProp = getProperties().wait; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void EnterDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr wait, ::mlir::ValueRange dataClauseOperands) { if (ifCond) odsState.addOperands(ifCond); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); odsState.addOperands(waitOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), static_cast(waitOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (async) { odsState.getOrAddProperties().async = async; } if (wait) { odsState.getOrAddProperties().wait = wait; } } EnterDataOp EnterDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr wait, ::mlir::ValueRange dataClauseOperands) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnterDataOp EnterDataOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr wait, ::mlir::ValueRange dataClauseOperands) { return create(builder, builder.getLoc(), std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands)); } void EnterDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr wait, ::mlir::ValueRange dataClauseOperands) { if (ifCond) odsState.addOperands(ifCond); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); odsState.addOperands(waitOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), static_cast(waitOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (async) { odsState.getOrAddProperties().async = async; } if (wait) { odsState.getOrAddProperties().wait = wait; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnterDataOp EnterDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr wait, ::mlir::ValueRange dataClauseOperands) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnterDataOp EnterDataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr wait, ::mlir::ValueRange dataClauseOperands) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands)); } void EnterDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/bool async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool wait, ::mlir::ValueRange dataClauseOperands) { if (ifCond) odsState.addOperands(ifCond); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); odsState.addOperands(waitOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), static_cast(waitOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (async) { odsState.getOrAddProperties().async = ((async) ? odsBuilder.getUnitAttr() : nullptr); } if (wait) { odsState.getOrAddProperties().wait = ((wait) ? odsBuilder.getUnitAttr() : nullptr); } } EnterDataOp EnterDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/bool async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool wait, ::mlir::ValueRange dataClauseOperands) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnterDataOp EnterDataOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/bool async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool wait, ::mlir::ValueRange dataClauseOperands) { return create(builder, builder.getLoc(), std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands)); } void EnterDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/bool async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool wait, ::mlir::ValueRange dataClauseOperands) { if (ifCond) odsState.addOperands(ifCond); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); odsState.addOperands(waitOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), static_cast(waitOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (async) { odsState.getOrAddProperties().async = ((async) ? odsBuilder.getUnitAttr() : nullptr); } if (wait) { odsState.getOrAddProperties().wait = ((wait) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } EnterDataOp EnterDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/bool async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool wait, ::mlir::ValueRange dataClauseOperands) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } EnterDataOp EnterDataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/bool async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool wait, ::mlir::ValueRange dataClauseOperands) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands)); } void EnterDataOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); 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."); } } EnterDataOp EnterDataOp::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__; } EnterDataOp EnterDataOp::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 EnterDataOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } EnterDataOp EnterDataOp::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__; } EnterDataOp EnterDataOp::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 EnterDataOp::verifyInvariantsImpl() { auto tblgen_async = getProperties().async; (void)tblgen_async; auto tblgen_wait = getProperties().wait; (void)tblgen_wait; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_async, "async"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_wait, "wait"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); if (valueGroup0.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup0.size(); } for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); if (valueGroup2.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup2.size(); } for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult EnterDataOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult EnterDataOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandOperands; ::llvm::SMLoc asyncOperandOperandsLoc; (void)asyncOperandOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandTypes; ::mlir::UnitAttr asyncAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> waitDevnumOperands; ::llvm::SMLoc waitDevnumOperandsLoc; (void)waitDevnumOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> waitDevnumTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> waitOperandsOperands; ::llvm::SMLoc waitOperandsOperandsLoc; (void)waitOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> waitOperandsTypes; ::mlir::UnitAttr waitAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dataClauseOperandsOperands; ::llvm::SMLoc dataClauseOperandsOperandsLoc; (void)dataClauseOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> dataClauseOperandsTypes; bool ifClause = false; bool asyncClause = false; bool wait_devnumClause = false; bool waitClause = false; bool dataOperandsClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandOperandsLoc = parser.getCurrentLocation(); ::std::optional<::mlir::OpAsmParser::UnresolvedOperand> asyncOperandOperand; ::mlir::Type asyncOperandType; auto odsResult = parseOperandWithKeywordOnly(parser, asyncOperandOperand, asyncOperandType, asyncAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandOperand.has_value()) asyncOperandOperands.push_back(*asyncOperandOperand); if (asyncOperandType) asyncOperandTypes.push_back(asyncOperandType); if (asyncAttr) result.getOrAddProperties().async = asyncAttr; } } else if (succeeded(parser.parseOptionalKeyword("wait_devnum"))) { if (wait_devnumClause) { return parser.emitError(parser.getNameLoc()) << "`wait_devnum` clause can appear at most once in the expansion of the " "oilist directive"; } wait_devnumClause = true; if (parser.parseLParen()) return ::mlir::failure(); { waitDevnumOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); waitDevnumOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); waitDevnumTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("wait"))) { if (waitClause) { return parser.emitError(parser.getNameLoc()) << "`wait` clause can appear at most once in the expansion of the " "oilist directive"; } waitClause = true; { waitOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseOperandsWithKeywordOnly(parser, waitOperandsOperands, waitOperandsTypes, waitAttr); if (odsResult) return ::mlir::failure(); if (waitAttr) result.getOrAddProperties().wait = waitAttr; } } else if (succeeded(parser.parseOptionalKeyword("dataOperands"))) { if (dataOperandsClause) { return parser.emitError(parser.getNameLoc()) << "`dataOperands` clause can appear at most once in the expansion of the " "oilist directive"; } dataOperandsClause = true; if (parser.parseLParen()) return ::mlir::failure(); dataClauseOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(dataClauseOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(dataClauseOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } { 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(); } ::llvm::copy(::llvm::ArrayRef({static_cast(ifCondOperands.size()), static_cast(asyncOperandOperands.size()), static_cast(waitDevnumOperands.size()), static_cast(waitOperandsOperands.size()), static_cast(dataClauseOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } if (!asyncOperandOperands.empty()) { if (parser.resolveOperands(asyncOperandOperands, asyncOperandTypes, asyncOperandOperandsLoc, result.operands)) return ::mlir::failure(); } if (!waitDevnumOperands.empty()) { if (parser.resolveOperands(waitDevnumOperands, waitDevnumTypes, waitDevnumOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(waitOperandsOperands, waitOperandsTypes, waitOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(dataClauseOperandsOperands, dataClauseOperandsTypes, dataClauseOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void EnterDataOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } if (false || getAsyncOperand() || ((getAsyncAttr() && getAsyncAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) { _odsPrinter << ' ' << "async"; printOperandWithKeywordOnly(_odsPrinter, *this, getAsyncOperand(), (getAsyncOperand() ? getAsyncOperand().getType() : ::mlir::Type()), getAsyncAttr()); } if (false || getWaitDevnum()) { _odsPrinter << ' ' << "wait_devnum"; _odsPrinter << "("; if (::mlir::Value value = getWaitDevnum()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getWaitDevnum() ? ::llvm::ArrayRef<::mlir::Type>(getWaitDevnum().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getWaitOperands().size() || ((getWaitAttr() && getWaitAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) { _odsPrinter << ' ' << "wait"; printOperandsWithKeywordOnly(_odsPrinter, *this, getWaitOperands(), getWaitOperands().getTypes(), getWaitAttr()); } if (false || getDataClauseOperands().size()) { _odsPrinter << ' ' << "dataOperands"; _odsPrinter << "("; _odsPrinter << getDataClauseOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getDataClauseOperands().getTypes(); _odsPrinter << ")"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("async"); elidedAttrs.push_back("wait"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getAsyncAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("async"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getWaitAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("wait"); } _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } void EnterDataOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::acc::ConstructResource::get()); effects.emplace_back(::mlir::MemoryEffects::Read::get(), 0, false, ::mlir::acc::CurrentDeviceIdResource::get()); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::EnterDataOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::EnterDataOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::ExitDataOp definitions //===----------------------------------------------------------------------===// namespace detail { ExitDataOpGenericAdaptorBase::ExitDataOpGenericAdaptorBase(ExitDataOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ExitDataOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::UnitAttr ExitDataOpGenericAdaptorBase::getAsyncAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().async); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool ExitDataOpGenericAdaptorBase::getAsync() { auto attr = getAsyncAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::mlir::UnitAttr ExitDataOpGenericAdaptorBase::getWaitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().wait); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool ExitDataOpGenericAdaptorBase::getWait() { auto attr = getWaitAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::mlir::UnitAttr ExitDataOpGenericAdaptorBase::getFinalizeAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().finalize); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool ExitDataOpGenericAdaptorBase::getFinalize() { auto attr = getFinalizeAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail ExitDataOpAdaptor::ExitDataOpAdaptor(ExitDataOp op) : ExitDataOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ExitDataOpAdaptor::verify(::mlir::Location loc) { auto tblgen_async = getProperties().async; (void)tblgen_async; auto tblgen_finalize = getProperties().finalize; (void)tblgen_finalize; auto tblgen_wait = getProperties().wait; (void)tblgen_wait; if (tblgen_async && !((::llvm::isa<::mlir::UnitAttr>(tblgen_async)))) return emitError(loc, "'acc.exit_data' op attribute 'async' failed to satisfy constraint: unit attribute"); if (tblgen_wait && !((::llvm::isa<::mlir::UnitAttr>(tblgen_wait)))) return emitError(loc, "'acc.exit_data' op attribute 'wait' failed to satisfy constraint: unit attribute"); if (tblgen_finalize && !((::llvm::isa<::mlir::UnitAttr>(tblgen_finalize)))) return emitError(loc, "'acc.exit_data' op attribute 'finalize' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } std::pair ExitDataOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange ExitDataOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ExitDataOp::getAsyncOperandMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ExitDataOp::getWaitDevnumMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ExitDataOp::getWaitOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ExitDataOp::getDataClauseOperandsMutable() { auto range = getODSOperandIndexAndLength(4); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(4u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult ExitDataOp::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.async; auto attr = dict.get("async"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `async` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.finalize; auto attr = dict.get("finalize"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `finalize` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.wait; auto attr = dict.get("wait"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `wait` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute ExitDataOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.async; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("async", propStorage)); } { const auto &propStorage = prop.finalize; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("finalize", propStorage)); } { const auto &propStorage = prop.wait; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("wait", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ExitDataOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.async.getAsOpaquePointer()), llvm::hash_value(prop.finalize.getAsOpaquePointer()), llvm::hash_value(prop.wait.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional ExitDataOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "async") return prop.async; if (name == "finalize") return prop.finalize; if (name == "wait") return prop.wait; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void ExitDataOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "async") { prop.async = ::llvm::dyn_cast_or_null>(value); return; } if (name == "finalize") { prop.finalize = ::llvm::dyn_cast_or_null>(value); return; } if (name == "wait") { prop.wait = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void ExitDataOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.async) attrs.append("async", prop.async); if (prop.finalize) attrs.append("finalize", prop.finalize); if (prop.wait) attrs.append("wait", prop.wait); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult ExitDataOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "async", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getFinalizeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "finalize", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "wait", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ExitDataOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.async))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.finalize))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.wait))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void ExitDataOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.async); writer.writeOptionalAttribute(prop.finalize); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.wait); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } bool ExitDataOp::getAsync() { auto attr = getAsyncAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } bool ExitDataOp::getWait() { auto attr = getWaitAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } bool ExitDataOp::getFinalize() { auto attr = getFinalizeAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void ExitDataOp::setAsync(bool attrValue) { auto &odsProp = getProperties().async; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void ExitDataOp::setWait(bool attrValue) { auto &odsProp = getProperties().wait; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void ExitDataOp::setFinalize(bool attrValue) { auto &odsProp = getProperties().finalize; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void ExitDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr wait, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr finalize) { if (ifCond) odsState.addOperands(ifCond); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); odsState.addOperands(waitOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), static_cast(waitOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (async) { odsState.getOrAddProperties().async = async; } if (wait) { odsState.getOrAddProperties().wait = wait; } if (finalize) { odsState.getOrAddProperties().finalize = finalize; } } ExitDataOp ExitDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr wait, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr finalize) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands), std::forward(finalize)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExitDataOp ExitDataOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr wait, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr finalize) { return create(builder, builder.getLoc(), std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands), std::forward(finalize)); } void ExitDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr wait, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr finalize) { if (ifCond) odsState.addOperands(ifCond); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); odsState.addOperands(waitOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), static_cast(waitOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (async) { odsState.getOrAddProperties().async = async; } if (wait) { odsState.getOrAddProperties().wait = wait; } if (finalize) { odsState.getOrAddProperties().finalize = finalize; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ExitDataOp ExitDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr wait, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr finalize) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands), std::forward(finalize)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExitDataOp ExitDataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr wait, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr finalize) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands), std::forward(finalize)); } void ExitDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/bool async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool wait, ::mlir::ValueRange dataClauseOperands, /*optional*/bool finalize) { if (ifCond) odsState.addOperands(ifCond); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); odsState.addOperands(waitOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), static_cast(waitOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (async) { odsState.getOrAddProperties().async = ((async) ? odsBuilder.getUnitAttr() : nullptr); } if (wait) { odsState.getOrAddProperties().wait = ((wait) ? odsBuilder.getUnitAttr() : nullptr); } if (finalize) { odsState.getOrAddProperties().finalize = ((finalize) ? odsBuilder.getUnitAttr() : nullptr); } } ExitDataOp ExitDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/bool async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool wait, ::mlir::ValueRange dataClauseOperands, /*optional*/bool finalize) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands), std::forward(finalize)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExitDataOp ExitDataOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/bool async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool wait, ::mlir::ValueRange dataClauseOperands, /*optional*/bool finalize) { return create(builder, builder.getLoc(), std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands), std::forward(finalize)); } void ExitDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/bool async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool wait, ::mlir::ValueRange dataClauseOperands, /*optional*/bool finalize) { if (ifCond) odsState.addOperands(ifCond); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); odsState.addOperands(waitOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), static_cast(waitOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (async) { odsState.getOrAddProperties().async = ((async) ? odsBuilder.getUnitAttr() : nullptr); } if (wait) { odsState.getOrAddProperties().wait = ((wait) ? odsBuilder.getUnitAttr() : nullptr); } if (finalize) { odsState.getOrAddProperties().finalize = ((finalize) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ExitDataOp ExitDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/bool async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool wait, ::mlir::ValueRange dataClauseOperands, /*optional*/bool finalize) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands), std::forward(finalize)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ExitDataOp ExitDataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value asyncOperand, /*optional*/bool async, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool wait, ::mlir::ValueRange dataClauseOperands, /*optional*/bool finalize) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ifCond), std::forward(asyncOperand), std::forward(async), std::forward(waitDevnum), std::forward(waitOperands), std::forward(wait), std::forward(dataClauseOperands), std::forward(finalize)); } void ExitDataOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); 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."); } } ExitDataOp ExitDataOp::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__; } ExitDataOp ExitDataOp::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 ExitDataOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ExitDataOp ExitDataOp::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__; } ExitDataOp ExitDataOp::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 ExitDataOp::verifyInvariantsImpl() { auto tblgen_async = getProperties().async; (void)tblgen_async; auto tblgen_finalize = getProperties().finalize; (void)tblgen_finalize; auto tblgen_wait = getProperties().wait; (void)tblgen_wait; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_async, "async"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_wait, "wait"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_finalize, "finalize"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); if (valueGroup0.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup0.size(); } for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); if (valueGroup2.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup2.size(); } for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ExitDataOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ExitDataOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandOperands; ::llvm::SMLoc asyncOperandOperandsLoc; (void)asyncOperandOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandTypes; ::mlir::UnitAttr asyncAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> waitDevnumOperands; ::llvm::SMLoc waitDevnumOperandsLoc; (void)waitDevnumOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> waitDevnumTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> waitOperandsOperands; ::llvm::SMLoc waitOperandsOperandsLoc; (void)waitOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> waitOperandsTypes; ::mlir::UnitAttr waitAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dataClauseOperandsOperands; ::llvm::SMLoc dataClauseOperandsOperandsLoc; (void)dataClauseOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> dataClauseOperandsTypes; bool ifClause = false; bool asyncClause = false; bool wait_devnumClause = false; bool waitClause = false; bool dataOperandsClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandOperandsLoc = parser.getCurrentLocation(); ::std::optional<::mlir::OpAsmParser::UnresolvedOperand> asyncOperandOperand; ::mlir::Type asyncOperandType; auto odsResult = parseOperandWithKeywordOnly(parser, asyncOperandOperand, asyncOperandType, asyncAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandOperand.has_value()) asyncOperandOperands.push_back(*asyncOperandOperand); if (asyncOperandType) asyncOperandTypes.push_back(asyncOperandType); if (asyncAttr) result.getOrAddProperties().async = asyncAttr; } } else if (succeeded(parser.parseOptionalKeyword("wait_devnum"))) { if (wait_devnumClause) { return parser.emitError(parser.getNameLoc()) << "`wait_devnum` clause can appear at most once in the expansion of the " "oilist directive"; } wait_devnumClause = true; if (parser.parseLParen()) return ::mlir::failure(); { waitDevnumOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); waitDevnumOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); waitDevnumTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("wait"))) { if (waitClause) { return parser.emitError(parser.getNameLoc()) << "`wait` clause can appear at most once in the expansion of the " "oilist directive"; } waitClause = true; { waitOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseOperandsWithKeywordOnly(parser, waitOperandsOperands, waitOperandsTypes, waitAttr); if (odsResult) return ::mlir::failure(); if (waitAttr) result.getOrAddProperties().wait = waitAttr; } } else if (succeeded(parser.parseOptionalKeyword("dataOperands"))) { if (dataOperandsClause) { return parser.emitError(parser.getNameLoc()) << "`dataOperands` clause can appear at most once in the expansion of the " "oilist directive"; } dataOperandsClause = true; if (parser.parseLParen()) return ::mlir::failure(); dataClauseOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(dataClauseOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(dataClauseOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } { 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(); } ::llvm::copy(::llvm::ArrayRef({static_cast(ifCondOperands.size()), static_cast(asyncOperandOperands.size()), static_cast(waitDevnumOperands.size()), static_cast(waitOperandsOperands.size()), static_cast(dataClauseOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } if (!asyncOperandOperands.empty()) { if (parser.resolveOperands(asyncOperandOperands, asyncOperandTypes, asyncOperandOperandsLoc, result.operands)) return ::mlir::failure(); } if (!waitDevnumOperands.empty()) { if (parser.resolveOperands(waitDevnumOperands, waitDevnumTypes, waitDevnumOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(waitOperandsOperands, waitOperandsTypes, waitOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(dataClauseOperandsOperands, dataClauseOperandsTypes, dataClauseOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ExitDataOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } if (false || getAsyncOperand() || ((getAsyncAttr() && getAsyncAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) { _odsPrinter << ' ' << "async"; printOperandWithKeywordOnly(_odsPrinter, *this, getAsyncOperand(), (getAsyncOperand() ? getAsyncOperand().getType() : ::mlir::Type()), getAsyncAttr()); } if (false || getWaitDevnum()) { _odsPrinter << ' ' << "wait_devnum"; _odsPrinter << "("; if (::mlir::Value value = getWaitDevnum()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getWaitDevnum() ? ::llvm::ArrayRef<::mlir::Type>(getWaitDevnum().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getWaitOperands().size() || ((getWaitAttr() && getWaitAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) { _odsPrinter << ' ' << "wait"; printOperandsWithKeywordOnly(_odsPrinter, *this, getWaitOperands(), getWaitOperands().getTypes(), getWaitAttr()); } if (false || getDataClauseOperands().size()) { _odsPrinter << ' ' << "dataOperands"; _odsPrinter << "("; _odsPrinter << getDataClauseOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getDataClauseOperands().getTypes(); _odsPrinter << ")"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("async"); elidedAttrs.push_back("wait"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getAsyncAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("async"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getWaitAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("wait"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getFinalizeAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("finalize"); } _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } void ExitDataOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::acc::ConstructResource::get()); effects.emplace_back(::mlir::MemoryEffects::Read::get(), 0, false, ::mlir::acc::CurrentDeviceIdResource::get()); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::ExitDataOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::ExitDataOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::FirstprivateMapInitialOp definitions //===----------------------------------------------------------------------===// namespace detail { FirstprivateMapInitialOpGenericAdaptorBase::FirstprivateMapInitialOpGenericAdaptorBase(FirstprivateMapInitialOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair FirstprivateMapInitialOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type FirstprivateMapInitialOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > FirstprivateMapInitialOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > FirstprivateMapInitialOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr FirstprivateMapInitialOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause FirstprivateMapInitialOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr FirstprivateMapInitialOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool FirstprivateMapInitialOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr FirstprivateMapInitialOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool FirstprivateMapInitialOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr FirstprivateMapInitialOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier FirstprivateMapInitialOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > FirstprivateMapInitialOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > FirstprivateMapInitialOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail FirstprivateMapInitialOpAdaptor::FirstprivateMapInitialOpAdaptor(FirstprivateMapInitialOp op) : FirstprivateMapInitialOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult FirstprivateMapInitialOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.firstprivate_map' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.firstprivate_map' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.firstprivate_map' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.firstprivate_map' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.firstprivate_map' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.firstprivate_map' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.firstprivate_map' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.firstprivate_map' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.firstprivate_map' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.firstprivate_map' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair FirstprivateMapInitialOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange FirstprivateMapInitialOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange FirstprivateMapInitialOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange FirstprivateMapInitialOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult FirstprivateMapInitialOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute FirstprivateMapInitialOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code FirstprivateMapInitialOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional FirstprivateMapInitialOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void FirstprivateMapInitialOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void FirstprivateMapInitialOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult FirstprivateMapInitialOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult FirstprivateMapInitialOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void FirstprivateMapInitialOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type FirstprivateMapInitialOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > FirstprivateMapInitialOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > FirstprivateMapInitialOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause FirstprivateMapInitialOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool FirstprivateMapInitialOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool FirstprivateMapInitialOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier FirstprivateMapInitialOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > FirstprivateMapInitialOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > FirstprivateMapInitialOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void FirstprivateMapInitialOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void FirstprivateMapInitialOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FirstprivateMapInitialOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void FirstprivateMapInitialOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void FirstprivateMapInitialOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FirstprivateMapInitialOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void FirstprivateMapInitialOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void FirstprivateMapInitialOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void FirstprivateMapInitialOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void FirstprivateMapInitialOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void FirstprivateMapInitialOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void FirstprivateMapInitialOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void FirstprivateMapInitialOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void FirstprivateMapInitialOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateMapInitialOp FirstprivateMapInitialOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void FirstprivateMapInitialOp::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."); } } FirstprivateMapInitialOp FirstprivateMapInitialOp::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__; } FirstprivateMapInitialOp FirstprivateMapInitialOp::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 FirstprivateMapInitialOp::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); } FirstprivateMapInitialOp FirstprivateMapInitialOp::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__; } FirstprivateMapInitialOp FirstprivateMapInitialOp::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 FirstprivateMapInitialOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_firstprivate); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult FirstprivateMapInitialOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult FirstprivateMapInitialOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult FirstprivateMapInitialOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void FirstprivateMapInitialOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_firstprivate))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::FirstprivateMapInitialOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::FirstprivateMapInitialOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::FirstprivateOp definitions //===----------------------------------------------------------------------===// namespace detail { FirstprivateOpGenericAdaptorBase::FirstprivateOpGenericAdaptorBase(FirstprivateOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair FirstprivateOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type FirstprivateOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > FirstprivateOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > FirstprivateOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr FirstprivateOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause FirstprivateOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr FirstprivateOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool FirstprivateOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr FirstprivateOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool FirstprivateOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr FirstprivateOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier FirstprivateOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > FirstprivateOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > FirstprivateOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail FirstprivateOpAdaptor::FirstprivateOpAdaptor(FirstprivateOp op) : FirstprivateOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult FirstprivateOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.firstprivate' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.firstprivate' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.firstprivate' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.firstprivate' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.firstprivate' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.firstprivate' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.firstprivate' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.firstprivate' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.firstprivate' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.firstprivate' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair FirstprivateOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange FirstprivateOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange FirstprivateOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange FirstprivateOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult FirstprivateOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute FirstprivateOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code FirstprivateOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional FirstprivateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void FirstprivateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void FirstprivateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult FirstprivateOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult FirstprivateOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void FirstprivateOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type FirstprivateOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > FirstprivateOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > FirstprivateOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause FirstprivateOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool FirstprivateOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool FirstprivateOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier FirstprivateOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > FirstprivateOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > FirstprivateOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void FirstprivateOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void FirstprivateOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FirstprivateOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void FirstprivateOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void FirstprivateOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void FirstprivateOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void FirstprivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } FirstprivateOp FirstprivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateOp FirstprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void FirstprivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } FirstprivateOp FirstprivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateOp FirstprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void FirstprivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } FirstprivateOp FirstprivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateOp FirstprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void FirstprivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } FirstprivateOp FirstprivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateOp FirstprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void FirstprivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } FirstprivateOp FirstprivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateOp FirstprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void FirstprivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } FirstprivateOp FirstprivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateOp FirstprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void FirstprivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } FirstprivateOp FirstprivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateOp FirstprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void FirstprivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } FirstprivateOp FirstprivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateOp FirstprivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void FirstprivateOp::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."); } } FirstprivateOp FirstprivateOp::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__; } FirstprivateOp FirstprivateOp::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 FirstprivateOp::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); } FirstprivateOp FirstprivateOp::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__; } FirstprivateOp FirstprivateOp::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 FirstprivateOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_firstprivate); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult FirstprivateOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult FirstprivateOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult FirstprivateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void FirstprivateOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_firstprivate))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::FirstprivateOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::FirstprivateOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::FirstprivateRecipeOp definitions //===----------------------------------------------------------------------===// namespace detail { FirstprivateRecipeOpGenericAdaptorBase::FirstprivateRecipeOpGenericAdaptorBase(FirstprivateRecipeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::llvm::StringRef FirstprivateRecipeOpGenericAdaptorBase::getSymName() { auto attr = getSymNameAttr(); return attr.getValue(); } ::mlir::Type FirstprivateRecipeOpGenericAdaptorBase::getType() { auto attr = getTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } } // namespace detail FirstprivateRecipeOpAdaptor::FirstprivateRecipeOpAdaptor(FirstprivateRecipeOp op) : FirstprivateRecipeOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult FirstprivateRecipeOpAdaptor::verify(::mlir::Location loc) { auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; if (!tblgen_sym_name) return emitError(loc, "'acc.firstprivate.recipe' op requires attribute 'sym_name'"); auto tblgen_type = getProperties().type; (void)tblgen_type; if (!tblgen_type) return emitError(loc, "'acc.firstprivate.recipe' op requires attribute 'type'"); if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name)))) return emitError(loc, "'acc.firstprivate.recipe' op attribute 'sym_name' failed to satisfy constraint: string attribute"); if (tblgen_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_type).getValue()))) && ((true)))) return emitError(loc, "'acc.firstprivate.recipe' op attribute 'type' failed to satisfy constraint: any type attribute"); return ::mlir::success(); } ::llvm::LogicalResult FirstprivateRecipeOp::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.type; auto attr = dict.get("type"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `type` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute FirstprivateRecipeOp::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.type; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("type", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code FirstprivateRecipeOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.sym_name.getAsOpaquePointer()), llvm::hash_value(prop.type.getAsOpaquePointer())); } std::optional FirstprivateRecipeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "sym_name") return prop.sym_name; if (name == "type") return prop.type; return std::nullopt; } void FirstprivateRecipeOp::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 == "type") { prop.type = ::llvm::dyn_cast_or_null>(value); return; } } void FirstprivateRecipeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.sym_name) attrs.append("sym_name", prop.sym_name); if (prop.type) attrs.append("type", prop.type); } ::llvm::LogicalResult FirstprivateRecipeOp::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_OpenACCOps6(attr, "sym_name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "type", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult FirstprivateRecipeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.sym_name))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.type))) return ::mlir::failure(); return ::mlir::success(); } void FirstprivateRecipeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.sym_name); writer.writeAttribute(prop.type); } ::llvm::StringRef FirstprivateRecipeOp::getSymName() { auto attr = getSymNameAttr(); return attr.getValue(); } ::mlir::Type FirstprivateRecipeOp::getType() { auto attr = getTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } void FirstprivateRecipeOp::setSymName(::llvm::StringRef attrValue) { getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue); } void FirstprivateRecipeOp::setType(::mlir::Type attrValue) { getProperties().type = ::mlir::TypeAttr::get(attrValue); } void FirstprivateRecipeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) { odsState.getOrAddProperties().sym_name = sym_name; odsState.getOrAddProperties().type = type; (void)odsState.addRegion(); (void)odsState.addRegion(); (void)odsState.addRegion(); } FirstprivateRecipeOp FirstprivateRecipeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sym_name), std::forward(type)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateRecipeOp FirstprivateRecipeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) { return create(builder, builder.getLoc(), std::forward(sym_name), std::forward(type)); } void FirstprivateRecipeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) { odsState.getOrAddProperties().sym_name = sym_name; odsState.getOrAddProperties().type = type; (void)odsState.addRegion(); (void)odsState.addRegion(); (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } FirstprivateRecipeOp FirstprivateRecipeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(sym_name), std::forward(type)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateRecipeOp FirstprivateRecipeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(sym_name), std::forward(type)); } void FirstprivateRecipeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, ::mlir::Type type) { odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); odsState.getOrAddProperties().type = ::mlir::TypeAttr::get(type); (void)odsState.addRegion(); (void)odsState.addRegion(); (void)odsState.addRegion(); } FirstprivateRecipeOp FirstprivateRecipeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef sym_name, ::mlir::Type type) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sym_name), std::forward(type)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateRecipeOp FirstprivateRecipeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llvm::StringRef sym_name, ::mlir::Type type) { return create(builder, builder.getLoc(), std::forward(sym_name), std::forward(type)); } void FirstprivateRecipeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type) { odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); odsState.getOrAddProperties().type = ::mlir::TypeAttr::get(type); (void)odsState.addRegion(); (void)odsState.addRegion(); (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } FirstprivateRecipeOp FirstprivateRecipeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(sym_name), std::forward(type)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } FirstprivateRecipeOp FirstprivateRecipeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(sym_name), std::forward(type)); } void FirstprivateRecipeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 3; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } FirstprivateRecipeOp FirstprivateRecipeOp::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__; } FirstprivateRecipeOp FirstprivateRecipeOp::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 FirstprivateRecipeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); for (unsigned i = 0; i != 3; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } FirstprivateRecipeOp FirstprivateRecipeOp::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__; } FirstprivateRecipeOp FirstprivateRecipeOp::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 FirstprivateRecipeOp::verifyInvariantsImpl() { auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'"); auto tblgen_type = getProperties().type; (void)tblgen_type; if (!tblgen_type) return emitOpError("requires attribute 'type'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_sym_name, "sym_name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_type, "type"))) return ::mlir::failure(); { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "initRegion", index++))) return ::mlir::failure(); for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "copyRegion", index++))) return ::mlir::failure(); for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(2))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "destroyRegion", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult FirstprivateRecipeOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult FirstprivateRecipeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::StringAttr sym_nameAttr; ::mlir::TypeAttr typeAttr; std::unique_ptr<::mlir::Region> initRegionRegion = std::make_unique<::mlir::Region>(); std::unique_ptr<::mlir::Region> copyRegionRegion = std::make_unique<::mlir::Region>(); std::unique_ptr<::mlir::Region> destroyRegionRegion = std::make_unique<::mlir::Region>(); if (parser.parseSymbolName(sym_nameAttr)) return ::mlir::failure(); if (sym_nameAttr) result.getOrAddProperties().sym_name = sym_nameAttr; if (parser.parseColon()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(typeAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (typeAttr) result.getOrAddProperties().type = typeAttr; { 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.parseKeyword("init")) return ::mlir::failure(); if (parser.parseRegion(*initRegionRegion)) return ::mlir::failure(); if (parser.parseKeyword("copy")) return ::mlir::failure(); if (parser.parseRegion(*copyRegionRegion)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("destroy"))) { if (parser.parseRegion(*destroyRegionRegion)) return ::mlir::failure(); } result.addRegion(std::move(initRegionRegion)); result.addRegion(std::move(copyRegionRegion)); result.addRegion(std::move(destroyRegionRegion)); return ::mlir::success(); } void FirstprivateRecipeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printSymbolName(getSymNameAttr().getValue()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getTypeAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("sym_name"); elidedAttrs.push_back("type"); _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << "init"; _odsPrinter << ' '; _odsPrinter.printRegion(getInitRegion()); _odsPrinter << ' ' << "copy"; _odsPrinter << ' '; _odsPrinter.printRegion(getCopyRegion()); if (!getDestroyRegion().empty()) { _odsPrinter << ' ' << "destroy"; _odsPrinter << ' '; _odsPrinter.printRegion(getDestroyRegion()); } } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::FirstprivateRecipeOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::FirstprivateRecipeOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::GetDevicePtrOp definitions //===----------------------------------------------------------------------===// namespace detail { GetDevicePtrOpGenericAdaptorBase::GetDevicePtrOpGenericAdaptorBase(GetDevicePtrOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair GetDevicePtrOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type GetDevicePtrOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > GetDevicePtrOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > GetDevicePtrOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr GetDevicePtrOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause GetDevicePtrOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr GetDevicePtrOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool GetDevicePtrOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr GetDevicePtrOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool GetDevicePtrOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr GetDevicePtrOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier GetDevicePtrOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > GetDevicePtrOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > GetDevicePtrOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail GetDevicePtrOpAdaptor::GetDevicePtrOpAdaptor(GetDevicePtrOp op) : GetDevicePtrOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GetDevicePtrOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.getdeviceptr' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.getdeviceptr' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.getdeviceptr' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.getdeviceptr' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.getdeviceptr' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.getdeviceptr' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.getdeviceptr' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.getdeviceptr' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.getdeviceptr' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.getdeviceptr' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair GetDevicePtrOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange GetDevicePtrOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange GetDevicePtrOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange GetDevicePtrOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult GetDevicePtrOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute GetDevicePtrOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code GetDevicePtrOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional GetDevicePtrOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void GetDevicePtrOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void GetDevicePtrOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult GetDevicePtrOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult GetDevicePtrOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void GetDevicePtrOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type GetDevicePtrOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > GetDevicePtrOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > GetDevicePtrOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause GetDevicePtrOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool GetDevicePtrOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool GetDevicePtrOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier GetDevicePtrOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > GetDevicePtrOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > GetDevicePtrOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void GetDevicePtrOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void GetDevicePtrOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void GetDevicePtrOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void GetDevicePtrOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void GetDevicePtrOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void GetDevicePtrOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void GetDevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } GetDevicePtrOp GetDevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetDevicePtrOp GetDevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void GetDevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } GetDevicePtrOp GetDevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetDevicePtrOp GetDevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void GetDevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } GetDevicePtrOp GetDevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetDevicePtrOp GetDevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void GetDevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } GetDevicePtrOp GetDevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetDevicePtrOp GetDevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void GetDevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } GetDevicePtrOp GetDevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetDevicePtrOp GetDevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void GetDevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } GetDevicePtrOp GetDevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetDevicePtrOp GetDevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void GetDevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } GetDevicePtrOp GetDevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetDevicePtrOp GetDevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void GetDevicePtrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } GetDevicePtrOp GetDevicePtrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetDevicePtrOp GetDevicePtrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void GetDevicePtrOp::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."); } } GetDevicePtrOp GetDevicePtrOp::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__; } GetDevicePtrOp GetDevicePtrOp::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 GetDevicePtrOp::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); } GetDevicePtrOp GetDevicePtrOp::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__; } GetDevicePtrOp GetDevicePtrOp::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 GetDevicePtrOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_getdeviceptr); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult GetDevicePtrOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult GetDevicePtrOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult GetDevicePtrOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void GetDevicePtrOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_getdeviceptr))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::GetDevicePtrOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::GetDevicePtrOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::GetExtentOp definitions //===----------------------------------------------------------------------===// namespace detail { GetExtentOpGenericAdaptorBase::GetExtentOpGenericAdaptorBase(GetExtentOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail GetExtentOpAdaptor::GetExtentOpAdaptor(GetExtentOp op) : GetExtentOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GetExtentOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult GetExtentOp::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 GetExtentOp::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 GetExtentOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional GetExtentOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void GetExtentOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void GetExtentOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult GetExtentOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void GetExtentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value bounds) { odsState.addOperands(bounds); odsState.addTypes(result); } GetExtentOp GetExtentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetExtentOp GetExtentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value bounds) { return create(builder, builder.getLoc(), std::forward(result), std::forward(bounds)); } void GetExtentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value bounds) { odsState.addOperands(bounds); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GetExtentOp::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); } GetExtentOp GetExtentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetExtentOp GetExtentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value bounds) { return create(builder, builder.getLoc(), std::forward(bounds)); } void GetExtentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value bounds) { odsState.addOperands(bounds); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } GetExtentOp GetExtentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetExtentOp GetExtentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value bounds) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(bounds)); } void GetExtentOp::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); } GetExtentOp GetExtentOp::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__; } GetExtentOp GetExtentOp::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 GetExtentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GetExtentOp::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)."); } } GetExtentOp GetExtentOp::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__; } GetExtentOp GetExtentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void GetExtentOp::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); } GetExtentOp GetExtentOp::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__; } GetExtentOp GetExtentOp::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 GetExtentOp::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(GetExtentOp::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)."); } } GetExtentOp GetExtentOp::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__; } GetExtentOp GetExtentOp::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 GetExtentOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps12(*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_OpenACCOps15(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult GetExtentOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult GetExtentOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult GetExtentOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand boundsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> boundsOperands(&boundsRawOperand, 1); ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::mlir::Type boundsRawType{}; ::llvm::ArrayRef<::mlir::Type> boundsTypes(&boundsRawType, 1); ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(boundsRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseLParen()) return ::mlir::failure(); { ::mlir::acc::DataBoundsType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); boundsRawType = type; } if (parser.parseRParen()) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::IndexType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resultRawType = type; } result.addTypes(resultTypes); if (parser.resolveOperands(boundsOperands, boundsTypes, boundsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void GetExtentOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getBounds(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' ' << "("; { auto type = getBounds().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::acc::DataBoundsType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ")"; _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getResult().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IndexType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void GetExtentOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::GetExtentOp) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::GetLowerboundOp definitions //===----------------------------------------------------------------------===// namespace detail { GetLowerboundOpGenericAdaptorBase::GetLowerboundOpGenericAdaptorBase(GetLowerboundOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail GetLowerboundOpAdaptor::GetLowerboundOpAdaptor(GetLowerboundOp op) : GetLowerboundOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GetLowerboundOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult GetLowerboundOp::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 GetLowerboundOp::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 GetLowerboundOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional GetLowerboundOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void GetLowerboundOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void GetLowerboundOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult GetLowerboundOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void GetLowerboundOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value bounds) { odsState.addOperands(bounds); odsState.addTypes(result); } GetLowerboundOp GetLowerboundOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetLowerboundOp GetLowerboundOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value bounds) { return create(builder, builder.getLoc(), std::forward(result), std::forward(bounds)); } void GetLowerboundOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value bounds) { odsState.addOperands(bounds); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GetLowerboundOp::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); } GetLowerboundOp GetLowerboundOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetLowerboundOp GetLowerboundOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value bounds) { return create(builder, builder.getLoc(), std::forward(bounds)); } void GetLowerboundOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value bounds) { odsState.addOperands(bounds); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } GetLowerboundOp GetLowerboundOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetLowerboundOp GetLowerboundOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value bounds) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(bounds)); } void GetLowerboundOp::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); } GetLowerboundOp GetLowerboundOp::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__; } GetLowerboundOp GetLowerboundOp::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 GetLowerboundOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GetLowerboundOp::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)."); } } GetLowerboundOp GetLowerboundOp::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__; } GetLowerboundOp GetLowerboundOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void GetLowerboundOp::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); } GetLowerboundOp GetLowerboundOp::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__; } GetLowerboundOp GetLowerboundOp::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 GetLowerboundOp::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(GetLowerboundOp::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)."); } } GetLowerboundOp GetLowerboundOp::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__; } GetLowerboundOp GetLowerboundOp::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 GetLowerboundOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps12(*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_OpenACCOps15(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult GetLowerboundOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult GetLowerboundOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult GetLowerboundOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand boundsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> boundsOperands(&boundsRawOperand, 1); ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::mlir::Type boundsRawType{}; ::llvm::ArrayRef<::mlir::Type> boundsTypes(&boundsRawType, 1); ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(boundsRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseLParen()) return ::mlir::failure(); { ::mlir::acc::DataBoundsType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); boundsRawType = type; } if (parser.parseRParen()) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::IndexType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resultRawType = type; } result.addTypes(resultTypes); if (parser.resolveOperands(boundsOperands, boundsTypes, boundsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void GetLowerboundOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getBounds(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' ' << "("; { auto type = getBounds().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::acc::DataBoundsType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ")"; _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getResult().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IndexType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void GetLowerboundOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::GetLowerboundOp) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::GetStrideOp definitions //===----------------------------------------------------------------------===// namespace detail { GetStrideOpGenericAdaptorBase::GetStrideOpGenericAdaptorBase(GetStrideOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail GetStrideOpAdaptor::GetStrideOpAdaptor(GetStrideOp op) : GetStrideOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GetStrideOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult GetStrideOp::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 GetStrideOp::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 GetStrideOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional GetStrideOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void GetStrideOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void GetStrideOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult GetStrideOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void GetStrideOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value bounds) { odsState.addOperands(bounds); odsState.addTypes(result); } GetStrideOp GetStrideOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetStrideOp GetStrideOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value bounds) { return create(builder, builder.getLoc(), std::forward(result), std::forward(bounds)); } void GetStrideOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value bounds) { odsState.addOperands(bounds); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GetStrideOp::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); } GetStrideOp GetStrideOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetStrideOp GetStrideOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value bounds) { return create(builder, builder.getLoc(), std::forward(bounds)); } void GetStrideOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value bounds) { odsState.addOperands(bounds); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } GetStrideOp GetStrideOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetStrideOp GetStrideOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value bounds) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(bounds)); } void GetStrideOp::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); } GetStrideOp GetStrideOp::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__; } GetStrideOp GetStrideOp::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 GetStrideOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GetStrideOp::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)."); } } GetStrideOp GetStrideOp::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__; } GetStrideOp GetStrideOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void GetStrideOp::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); } GetStrideOp GetStrideOp::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__; } GetStrideOp GetStrideOp::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 GetStrideOp::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(GetStrideOp::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)."); } } GetStrideOp GetStrideOp::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__; } GetStrideOp GetStrideOp::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 GetStrideOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps12(*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_OpenACCOps15(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult GetStrideOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult GetStrideOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult GetStrideOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand boundsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> boundsOperands(&boundsRawOperand, 1); ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::mlir::Type boundsRawType{}; ::llvm::ArrayRef<::mlir::Type> boundsTypes(&boundsRawType, 1); ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(boundsRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseLParen()) return ::mlir::failure(); { ::mlir::acc::DataBoundsType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); boundsRawType = type; } if (parser.parseRParen()) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::IndexType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resultRawType = type; } result.addTypes(resultTypes); if (parser.resolveOperands(boundsOperands, boundsTypes, boundsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void GetStrideOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getBounds(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' ' << "("; { auto type = getBounds().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::acc::DataBoundsType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ")"; _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getResult().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IndexType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void GetStrideOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::GetStrideOp) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::GetUpperboundOp definitions //===----------------------------------------------------------------------===// namespace detail { GetUpperboundOpGenericAdaptorBase::GetUpperboundOpGenericAdaptorBase(GetUpperboundOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail GetUpperboundOpAdaptor::GetUpperboundOpAdaptor(GetUpperboundOp op) : GetUpperboundOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GetUpperboundOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult GetUpperboundOp::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 GetUpperboundOp::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 GetUpperboundOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional GetUpperboundOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void GetUpperboundOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void GetUpperboundOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult GetUpperboundOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void GetUpperboundOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value bounds) { odsState.addOperands(bounds); odsState.addTypes(result); } GetUpperboundOp GetUpperboundOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetUpperboundOp GetUpperboundOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value bounds) { return create(builder, builder.getLoc(), std::forward(result), std::forward(bounds)); } void GetUpperboundOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value bounds) { odsState.addOperands(bounds); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GetUpperboundOp::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); } GetUpperboundOp GetUpperboundOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetUpperboundOp GetUpperboundOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value bounds) { return create(builder, builder.getLoc(), std::forward(bounds)); } void GetUpperboundOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value bounds) { odsState.addOperands(bounds); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } GetUpperboundOp GetUpperboundOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GetUpperboundOp GetUpperboundOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value bounds) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(bounds)); } void GetUpperboundOp::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); } GetUpperboundOp GetUpperboundOp::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__; } GetUpperboundOp GetUpperboundOp::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 GetUpperboundOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 1u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(GetUpperboundOp::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)."); } } GetUpperboundOp GetUpperboundOp::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__; } GetUpperboundOp GetUpperboundOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void GetUpperboundOp::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); } GetUpperboundOp GetUpperboundOp::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__; } GetUpperboundOp GetUpperboundOp::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 GetUpperboundOp::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(GetUpperboundOp::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)."); } } GetUpperboundOp GetUpperboundOp::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__; } GetUpperboundOp GetUpperboundOp::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 GetUpperboundOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps12(*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_OpenACCOps15(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult GetUpperboundOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult GetUpperboundOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult GetUpperboundOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand boundsRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> boundsOperands(&boundsRawOperand, 1); ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::mlir::Type boundsRawType{}; ::llvm::ArrayRef<::mlir::Type> boundsTypes(&boundsRawType, 1); ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(boundsRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseLParen()) return ::mlir::failure(); { ::mlir::acc::DataBoundsType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); boundsRawType = type; } if (parser.parseRParen()) return ::mlir::failure(); if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::IndexType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resultRawType = type; } result.addTypes(resultTypes); if (parser.resolveOperands(boundsOperands, boundsTypes, boundsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void GetUpperboundOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getBounds(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' ' << "("; { auto type = getBounds().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::acc::DataBoundsType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ")"; _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getResult().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::IndexType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void GetUpperboundOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::GetUpperboundOp) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::GlobalConstructorOp definitions //===----------------------------------------------------------------------===// namespace detail { GlobalConstructorOpGenericAdaptorBase::GlobalConstructorOpGenericAdaptorBase(GlobalConstructorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::llvm::StringRef GlobalConstructorOpGenericAdaptorBase::getSymName() { auto attr = getSymNameAttr(); return attr.getValue(); } } // namespace detail GlobalConstructorOpAdaptor::GlobalConstructorOpAdaptor(GlobalConstructorOp op) : GlobalConstructorOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GlobalConstructorOpAdaptor::verify(::mlir::Location loc) { auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; if (!tblgen_sym_name) return emitError(loc, "'acc.global_ctor' op requires attribute 'sym_name'"); if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name)))) return emitError(loc, "'acc.global_ctor' op attribute 'sym_name' failed to satisfy constraint: string attribute"); return ::mlir::success(); } ::llvm::LogicalResult GlobalConstructorOp::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(); } } } return ::mlir::success(); } ::mlir::Attribute GlobalConstructorOp::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)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code GlobalConstructorOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.sym_name.getAsOpaquePointer())); } std::optional GlobalConstructorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "sym_name") return prop.sym_name; return std::nullopt; } void GlobalConstructorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "sym_name") { prop.sym_name = ::llvm::dyn_cast_or_null>(value); return; } } void GlobalConstructorOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.sym_name) attrs.append("sym_name", prop.sym_name); } ::llvm::LogicalResult GlobalConstructorOp::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_OpenACCOps6(attr, "sym_name", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult GlobalConstructorOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.sym_name))) return ::mlir::failure(); return ::mlir::success(); } void GlobalConstructorOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.sym_name); } ::llvm::StringRef GlobalConstructorOp::getSymName() { auto attr = getSymNameAttr(); return attr.getValue(); } void GlobalConstructorOp::setSymName(::llvm::StringRef attrValue) { getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue); } void GlobalConstructorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name) { odsState.getOrAddProperties().sym_name = sym_name; (void)odsState.addRegion(); } GlobalConstructorOp GlobalConstructorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::StringAttr sym_name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sym_name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalConstructorOp GlobalConstructorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::StringAttr sym_name) { return create(builder, builder.getLoc(), std::forward(sym_name)); } void GlobalConstructorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name) { odsState.getOrAddProperties().sym_name = sym_name; (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } GlobalConstructorOp GlobalConstructorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(sym_name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalConstructorOp GlobalConstructorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(sym_name)); } void GlobalConstructorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name) { odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); (void)odsState.addRegion(); } GlobalConstructorOp GlobalConstructorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef sym_name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sym_name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalConstructorOp GlobalConstructorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llvm::StringRef sym_name) { return create(builder, builder.getLoc(), std::forward(sym_name)); } void GlobalConstructorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name) { odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } GlobalConstructorOp GlobalConstructorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(sym_name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalConstructorOp GlobalConstructorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(sym_name)); } void GlobalConstructorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } GlobalConstructorOp GlobalConstructorOp::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__; } GlobalConstructorOp GlobalConstructorOp::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 GlobalConstructorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } GlobalConstructorOp GlobalConstructorOp::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__; } GlobalConstructorOp GlobalConstructorOp::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 GlobalConstructorOp::verifyInvariantsImpl() { auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_sym_name, "sym_name"))) return ::mlir::failure(); { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult GlobalConstructorOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult GlobalConstructorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::StringAttr sym_nameAttr; std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); if (parser.parseSymbolName(sym_nameAttr)) return ::mlir::failure(); if (sym_nameAttr) result.getOrAddProperties().sym_name = sym_nameAttr; if (parser.parseRegion(*regionRegion)) return ::mlir::failure(); { 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(); } result.addRegion(std::move(regionRegion)); return ::mlir::success(); } void GlobalConstructorOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printSymbolName(getSymNameAttr().getValue()); _odsPrinter << ' '; _odsPrinter.printRegion(getRegion()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("sym_name"); _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::GlobalConstructorOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::GlobalConstructorOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::GlobalDestructorOp definitions //===----------------------------------------------------------------------===// namespace detail { GlobalDestructorOpGenericAdaptorBase::GlobalDestructorOpGenericAdaptorBase(GlobalDestructorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::llvm::StringRef GlobalDestructorOpGenericAdaptorBase::getSymName() { auto attr = getSymNameAttr(); return attr.getValue(); } } // namespace detail GlobalDestructorOpAdaptor::GlobalDestructorOpAdaptor(GlobalDestructorOp op) : GlobalDestructorOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult GlobalDestructorOpAdaptor::verify(::mlir::Location loc) { auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; if (!tblgen_sym_name) return emitError(loc, "'acc.global_dtor' op requires attribute 'sym_name'"); if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name)))) return emitError(loc, "'acc.global_dtor' op attribute 'sym_name' failed to satisfy constraint: string attribute"); return ::mlir::success(); } ::llvm::LogicalResult GlobalDestructorOp::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(); } } } return ::mlir::success(); } ::mlir::Attribute GlobalDestructorOp::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)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code GlobalDestructorOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.sym_name.getAsOpaquePointer())); } std::optional GlobalDestructorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "sym_name") return prop.sym_name; return std::nullopt; } void GlobalDestructorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "sym_name") { prop.sym_name = ::llvm::dyn_cast_or_null>(value); return; } } void GlobalDestructorOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.sym_name) attrs.append("sym_name", prop.sym_name); } ::llvm::LogicalResult GlobalDestructorOp::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_OpenACCOps6(attr, "sym_name", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult GlobalDestructorOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.sym_name))) return ::mlir::failure(); return ::mlir::success(); } void GlobalDestructorOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.sym_name); } ::llvm::StringRef GlobalDestructorOp::getSymName() { auto attr = getSymNameAttr(); return attr.getValue(); } void GlobalDestructorOp::setSymName(::llvm::StringRef attrValue) { getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue); } void GlobalDestructorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name) { odsState.getOrAddProperties().sym_name = sym_name; (void)odsState.addRegion(); } GlobalDestructorOp GlobalDestructorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::StringAttr sym_name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sym_name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalDestructorOp GlobalDestructorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::StringAttr sym_name) { return create(builder, builder.getLoc(), std::forward(sym_name)); } void GlobalDestructorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name) { odsState.getOrAddProperties().sym_name = sym_name; (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } GlobalDestructorOp GlobalDestructorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(sym_name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalDestructorOp GlobalDestructorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(sym_name)); } void GlobalDestructorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name) { odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); (void)odsState.addRegion(); } GlobalDestructorOp GlobalDestructorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef sym_name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sym_name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalDestructorOp GlobalDestructorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llvm::StringRef sym_name) { return create(builder, builder.getLoc(), std::forward(sym_name)); } void GlobalDestructorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name) { odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } GlobalDestructorOp GlobalDestructorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(sym_name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } GlobalDestructorOp GlobalDestructorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(sym_name)); } void GlobalDestructorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } GlobalDestructorOp GlobalDestructorOp::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__; } GlobalDestructorOp GlobalDestructorOp::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 GlobalDestructorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } GlobalDestructorOp GlobalDestructorOp::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__; } GlobalDestructorOp GlobalDestructorOp::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 GlobalDestructorOp::verifyInvariantsImpl() { auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_sym_name, "sym_name"))) return ::mlir::failure(); { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult GlobalDestructorOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult GlobalDestructorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::StringAttr sym_nameAttr; std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); if (parser.parseSymbolName(sym_nameAttr)) return ::mlir::failure(); if (sym_nameAttr) result.getOrAddProperties().sym_name = sym_nameAttr; if (parser.parseRegion(*regionRegion)) return ::mlir::failure(); { 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(); } result.addRegion(std::move(regionRegion)); return ::mlir::success(); } void GlobalDestructorOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printSymbolName(getSymNameAttr().getValue()); _odsPrinter << ' '; _odsPrinter.printRegion(getRegion()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("sym_name"); _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::GlobalDestructorOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::GlobalDestructorOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::HostDataOp definitions //===----------------------------------------------------------------------===// namespace detail { HostDataOpGenericAdaptorBase::HostDataOpGenericAdaptorBase(HostDataOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair HostDataOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::UnitAttr HostDataOpGenericAdaptorBase::getIfPresentAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().ifPresent); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool HostDataOpGenericAdaptorBase::getIfPresent() { auto attr = getIfPresentAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail HostDataOpAdaptor::HostDataOpAdaptor(HostDataOp op) : HostDataOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult HostDataOpAdaptor::verify(::mlir::Location loc) { auto tblgen_ifPresent = getProperties().ifPresent; (void)tblgen_ifPresent; if (tblgen_ifPresent && !((::llvm::isa<::mlir::UnitAttr>(tblgen_ifPresent)))) return emitError(loc, "'acc.host_data' op attribute 'ifPresent' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } std::pair HostDataOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange HostDataOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange HostDataOp::getDataClauseOperandsMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult HostDataOp::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.ifPresent; auto attr = dict.get("ifPresent"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ifPresent` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute HostDataOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.ifPresent; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ifPresent", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code HostDataOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.ifPresent.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional HostDataOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "ifPresent") return prop.ifPresent; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void HostDataOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "ifPresent") { prop.ifPresent = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void HostDataOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.ifPresent) attrs.append("ifPresent", prop.ifPresent); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult HostDataOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getIfPresentAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "ifPresent", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult HostDataOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.ifPresent))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void HostDataOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.ifPresent); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } bool HostDataOp::getIfPresent() { auto attr = getIfPresentAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void HostDataOp::setIfPresent(bool attrValue) { auto &odsProp = getProperties().ifPresent; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void HostDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr ifPresent) { if (ifCond) odsState.addOperands(ifCond); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (ifPresent) { odsState.getOrAddProperties().ifPresent = ifPresent; } (void)odsState.addRegion(); } HostDataOp HostDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr ifPresent) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ifCond), std::forward(dataClauseOperands), std::forward(ifPresent)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } HostDataOp HostDataOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr ifPresent) { return create(builder, builder.getLoc(), std::forward(ifCond), std::forward(dataClauseOperands), std::forward(ifPresent)); } void HostDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr ifPresent) { if (ifCond) odsState.addOperands(ifCond); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (ifPresent) { odsState.getOrAddProperties().ifPresent = ifPresent; } (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } HostDataOp HostDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr ifPresent) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ifCond), std::forward(dataClauseOperands), std::forward(ifPresent)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } HostDataOp HostDataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr ifPresent) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ifCond), std::forward(dataClauseOperands), std::forward(ifPresent)); } void HostDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange dataClauseOperands, /*optional*/bool ifPresent) { if (ifCond) odsState.addOperands(ifCond); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (ifPresent) { odsState.getOrAddProperties().ifPresent = ((ifPresent) ? odsBuilder.getUnitAttr() : nullptr); } (void)odsState.addRegion(); } HostDataOp HostDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange dataClauseOperands, /*optional*/bool ifPresent) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ifCond), std::forward(dataClauseOperands), std::forward(ifPresent)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } HostDataOp HostDataOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange dataClauseOperands, /*optional*/bool ifPresent) { return create(builder, builder.getLoc(), std::forward(ifCond), std::forward(dataClauseOperands), std::forward(ifPresent)); } void HostDataOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange dataClauseOperands, /*optional*/bool ifPresent) { if (ifCond) odsState.addOperands(ifCond); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (ifPresent) { odsState.getOrAddProperties().ifPresent = ((ifPresent) ? odsBuilder.getUnitAttr() : nullptr); } (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } HostDataOp HostDataOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange dataClauseOperands, /*optional*/bool ifPresent) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ifCond), std::forward(dataClauseOperands), std::forward(ifPresent)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } HostDataOp HostDataOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange dataClauseOperands, /*optional*/bool ifPresent) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ifCond), std::forward(dataClauseOperands), std::forward(ifPresent)); } void HostDataOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } HostDataOp HostDataOp::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__; } HostDataOp HostDataOp::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 HostDataOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } HostDataOp HostDataOp::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__; } HostDataOp HostDataOp::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 HostDataOp::verifyInvariantsImpl() { auto tblgen_ifPresent = getProperties().ifPresent; (void)tblgen_ifPresent; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_ifPresent, "ifPresent"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); if (valueGroup0.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup0.size(); } for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult HostDataOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult HostDataOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dataClauseOperandsOperands; ::llvm::SMLoc dataClauseOperandsOperandsLoc; (void)dataClauseOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> dataClauseOperandsTypes; std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); bool ifClause = false; bool dataOperandsClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("dataOperands"))) { if (dataOperandsClause) { return parser.emitError(parser.getNameLoc()) << "`dataOperands` clause can appear at most once in the expansion of the " "oilist directive"; } dataOperandsClause = true; if (parser.parseLParen()) return ::mlir::failure(); dataClauseOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(dataClauseOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(dataClauseOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseRegion(*regionRegion)) return ::mlir::failure(); { 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(); } result.addRegion(std::move(regionRegion)); ::llvm::copy(::llvm::ArrayRef({static_cast(ifCondOperands.size()), static_cast(dataClauseOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(dataClauseOperandsOperands, dataClauseOperandsTypes, dataClauseOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void HostDataOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } if (false || getDataClauseOperands().size()) { _odsPrinter << ' ' << "dataOperands"; _odsPrinter << "("; _odsPrinter << getDataClauseOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getDataClauseOperands().getTypes(); _odsPrinter << ")"; } _odsPrinter << ' '; _odsPrinter.printRegion(getRegion()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getIfPresentAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("ifPresent"); } _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } void HostDataOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::acc::ConstructResource::get()); effects.emplace_back(::mlir::MemoryEffects::Read::get(), 0, false, ::mlir::acc::CurrentDeviceIdResource::get()); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::HostDataOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::HostDataOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::InitOp definitions //===----------------------------------------------------------------------===// namespace detail { InitOpGenericAdaptorBase::InitOpGenericAdaptorBase(InitOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair InitOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::std::optional< ::mlir::ArrayAttr > InitOpGenericAdaptorBase::getDeviceTypes() { auto attr = getDeviceTypesAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } } // namespace detail InitOpAdaptor::InitOpAdaptor(InitOp op) : InitOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult InitOpAdaptor::verify(::mlir::Location loc) { auto tblgen_device_types = getProperties().device_types; (void)tblgen_device_types; if (tblgen_device_types && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_device_types))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_device_types), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.init' op attribute 'device_types' failed to satisfy constraint: Device type attributes"); return ::mlir::success(); } std::pair InitOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange InitOp::getDeviceNumMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange InitOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult InitOp::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.device_types; auto attr = dict.get("device_types"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `device_types` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute InitOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.device_types; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("device_types", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code InitOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.device_types.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional InitOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "device_types") return prop.device_types; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void InitOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "device_types") { prop.device_types = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void InitOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.device_types) attrs.append("device_types", prop.device_types); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult InitOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getDeviceTypesAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps13(attr, "device_types", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult InitOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.device_types))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void InitOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.device_types); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::std::optional< ::mlir::ArrayAttr > InitOp::getDeviceTypes() { auto attr = getDeviceTypesAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } void InitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::ArrayAttr device_types, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { if (deviceNum) odsState.addOperands(deviceNum); if (ifCond) odsState.addOperands(ifCond); ::llvm::copy(::llvm::ArrayRef({(deviceNum ? 1 : 0), (ifCond ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (device_types) { odsState.getOrAddProperties().device_types = device_types; } } InitOp InitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::ArrayAttr device_types, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(device_types), std::forward(deviceNum), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } InitOp InitOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::ArrayAttr device_types, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(device_types), std::forward(deviceNum), std::forward(ifCond)); } void InitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr device_types, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { if (deviceNum) odsState.addOperands(deviceNum); if (ifCond) odsState.addOperands(ifCond); ::llvm::copy(::llvm::ArrayRef({(deviceNum ? 1 : 0), (ifCond ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (device_types) { odsState.getOrAddProperties().device_types = device_types; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } InitOp InitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr device_types, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(device_types), std::forward(deviceNum), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } InitOp InitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr device_types, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(device_types), std::forward(deviceNum), std::forward(ifCond)); } void InitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); 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."); } } InitOp InitOp::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__; } InitOp InitOp::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 InitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } InitOp InitOp::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__; } InitOp InitOp::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 InitOp::verifyInvariantsImpl() { auto tblgen_device_types = getProperties().device_types; (void)tblgen_device_types; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps13(*this, tblgen_device_types, "device_types"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); if (valueGroup0.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup0.size(); } for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult InitOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult InitOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> deviceNumOperands; ::llvm::SMLoc deviceNumOperandsLoc; (void)deviceNumOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> deviceNumTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; bool device_numClause = false; bool ifClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("device_num"))) { if (device_numClause) { return parser.emitError(parser.getNameLoc()) << "`device_num` clause can appear at most once in the expansion of the " "oilist directive"; } device_numClause = true; if (parser.parseLParen()) return ::mlir::failure(); { deviceNumOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); deviceNumOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); deviceNumTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } { 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(); } ::llvm::copy(::llvm::ArrayRef({static_cast(deviceNumOperands.size()), static_cast(ifCondOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (!deviceNumOperands.empty()) { if (parser.resolveOperands(deviceNumOperands, deviceNumTypes, deviceNumOperandsLoc, result.operands)) return ::mlir::failure(); } if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void InitOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getDeviceNum()) { _odsPrinter << ' ' << "device_num"; _odsPrinter << "("; if (::mlir::Value value = getDeviceNum()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getDeviceNum() ? ::llvm::ArrayRef<::mlir::Type>(getDeviceNum().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::InitOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::InitOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::KernelEnvironmentOp definitions //===----------------------------------------------------------------------===// namespace detail { KernelEnvironmentOpGenericAdaptorBase::KernelEnvironmentOpGenericAdaptorBase(KernelEnvironmentOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair KernelEnvironmentOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::UnitAttr KernelEnvironmentOpGenericAdaptorBase::getAsyncOnlyAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().asyncOnly); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool KernelEnvironmentOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::mlir::UnitAttr KernelEnvironmentOpGenericAdaptorBase::getWaitOnlyAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().waitOnly); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool KernelEnvironmentOpGenericAdaptorBase::getWaitOnly() { auto attr = getWaitOnlyAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail KernelEnvironmentOpAdaptor::KernelEnvironmentOpAdaptor(KernelEnvironmentOp op) : KernelEnvironmentOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult KernelEnvironmentOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_waitOnly = getProperties().waitOnly; (void)tblgen_waitOnly; if (tblgen_asyncOnly && !((::llvm::isa<::mlir::UnitAttr>(tblgen_asyncOnly)))) return emitError(loc, "'acc.kernel_environment' op attribute 'asyncOnly' failed to satisfy constraint: unit attribute"); if (tblgen_waitOnly && !((::llvm::isa<::mlir::UnitAttr>(tblgen_waitOnly)))) return emitError(loc, "'acc.kernel_environment' op attribute 'waitOnly' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } std::pair KernelEnvironmentOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange KernelEnvironmentOp::getDataClauseOperandsMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange KernelEnvironmentOp::getAsyncOperandMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange KernelEnvironmentOp::getWaitDevnumMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange KernelEnvironmentOp::getWaitOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult KernelEnvironmentOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOnly; auto attr = dict.get("waitOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute KernelEnvironmentOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.waitOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOnly", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code KernelEnvironmentOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.waitOnly.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional KernelEnvironmentOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "waitOnly") return prop.waitOnly; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void KernelEnvironmentOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOnly") { prop.waitOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void KernelEnvironmentOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.waitOnly) attrs.append("waitOnly", prop.waitOnly); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult KernelEnvironmentOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "waitOnly", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult KernelEnvironmentOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.waitOnly))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void KernelEnvironmentOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.waitOnly); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } bool KernelEnvironmentOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } bool KernelEnvironmentOp::getWaitOnly() { auto attr = getWaitOnlyAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void KernelEnvironmentOp::setAsyncOnly(bool attrValue) { auto &odsProp = getProperties().asyncOnly; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void KernelEnvironmentOp::setWaitOnly(bool attrValue) { auto &odsProp = getProperties().waitOnly; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void KernelEnvironmentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr asyncOnly, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr waitOnly) { odsState.addOperands(dataClauseOperands); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); odsState.addOperands(waitOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(dataClauseOperands.size()), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), static_cast(waitOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } (void)odsState.addRegion(); } KernelEnvironmentOp KernelEnvironmentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr asyncOnly, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr waitOnly) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dataClauseOperands), std::forward(asyncOperand), std::forward(asyncOnly), std::forward(waitDevnum), std::forward(waitOperands), std::forward(waitOnly)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } KernelEnvironmentOp KernelEnvironmentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr asyncOnly, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr waitOnly) { return create(builder, builder.getLoc(), std::forward(dataClauseOperands), std::forward(asyncOperand), std::forward(asyncOnly), std::forward(waitDevnum), std::forward(waitOperands), std::forward(waitOnly)); } void KernelEnvironmentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr asyncOnly, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr waitOnly) { odsState.addOperands(dataClauseOperands); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); odsState.addOperands(waitOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(dataClauseOperands.size()), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), static_cast(waitOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } KernelEnvironmentOp KernelEnvironmentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr asyncOnly, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr waitOnly) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(dataClauseOperands), std::forward(asyncOperand), std::forward(asyncOnly), std::forward(waitDevnum), std::forward(waitOperands), std::forward(waitOnly)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } KernelEnvironmentOp KernelEnvironmentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::UnitAttr asyncOnly, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/::mlir::UnitAttr waitOnly) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(dataClauseOperands), std::forward(asyncOperand), std::forward(asyncOnly), std::forward(waitDevnum), std::forward(waitOperands), std::forward(waitOnly)); } void KernelEnvironmentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/bool asyncOnly, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool waitOnly) { odsState.addOperands(dataClauseOperands); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); odsState.addOperands(waitOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(dataClauseOperands.size()), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), static_cast(waitOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = ((asyncOnly) ? odsBuilder.getUnitAttr() : nullptr); } if (waitOnly) { odsState.getOrAddProperties().waitOnly = ((waitOnly) ? odsBuilder.getUnitAttr() : nullptr); } (void)odsState.addRegion(); } KernelEnvironmentOp KernelEnvironmentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/bool asyncOnly, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool waitOnly) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(dataClauseOperands), std::forward(asyncOperand), std::forward(asyncOnly), std::forward(waitDevnum), std::forward(waitOperands), std::forward(waitOnly)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } KernelEnvironmentOp KernelEnvironmentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/bool asyncOnly, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool waitOnly) { return create(builder, builder.getLoc(), std::forward(dataClauseOperands), std::forward(asyncOperand), std::forward(asyncOnly), std::forward(waitDevnum), std::forward(waitOperands), std::forward(waitOnly)); } void KernelEnvironmentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/bool asyncOnly, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool waitOnly) { odsState.addOperands(dataClauseOperands); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); odsState.addOperands(waitOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(dataClauseOperands.size()), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), static_cast(waitOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = ((asyncOnly) ? odsBuilder.getUnitAttr() : nullptr); } if (waitOnly) { odsState.getOrAddProperties().waitOnly = ((waitOnly) ? odsBuilder.getUnitAttr() : nullptr); } (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } KernelEnvironmentOp KernelEnvironmentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/bool asyncOnly, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool waitOnly) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(dataClauseOperands), std::forward(asyncOperand), std::forward(asyncOnly), std::forward(waitDevnum), std::forward(waitOperands), std::forward(waitOnly)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } KernelEnvironmentOp KernelEnvironmentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/bool asyncOnly, /*optional*/::mlir::Value waitDevnum, ::mlir::ValueRange waitOperands, /*optional*/bool waitOnly) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(dataClauseOperands), std::forward(asyncOperand), std::forward(asyncOnly), std::forward(waitDevnum), std::forward(waitOperands), std::forward(waitOnly)); } void KernelEnvironmentOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } KernelEnvironmentOp KernelEnvironmentOp::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__; } KernelEnvironmentOp KernelEnvironmentOp::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 KernelEnvironmentOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } KernelEnvironmentOp KernelEnvironmentOp::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__; } KernelEnvironmentOp KernelEnvironmentOp::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 KernelEnvironmentOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_waitOnly = getProperties().waitOnly; (void)tblgen_waitOnly; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_waitOnly, "waitOnly"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps9(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); if (valueGroup2.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup2.size(); } for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps1(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult KernelEnvironmentOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult KernelEnvironmentOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dataClauseOperandsOperands; ::llvm::SMLoc dataClauseOperandsOperandsLoc; (void)dataClauseOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> dataClauseOperandsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandOperands; ::llvm::SMLoc asyncOperandOperandsLoc; (void)asyncOperandOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandTypes; ::mlir::UnitAttr asyncOnlyAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> waitDevnumOperands; ::llvm::SMLoc waitDevnumOperandsLoc; (void)waitDevnumOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> waitDevnumTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> waitOperandsOperands; ::llvm::SMLoc waitOperandsOperandsLoc; (void)waitOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> waitOperandsTypes; ::mlir::UnitAttr waitOnlyAttr; std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); bool dataOperandsClause = false; bool asyncClause = false; bool wait_devnumClause = false; bool waitClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("dataOperands"))) { if (dataOperandsClause) { return parser.emitError(parser.getNameLoc()) << "`dataOperands` clause can appear at most once in the expansion of the " "oilist directive"; } dataOperandsClause = true; if (parser.parseLParen()) return ::mlir::failure(); dataClauseOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(dataClauseOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(dataClauseOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandOperandsLoc = parser.getCurrentLocation(); ::std::optional<::mlir::OpAsmParser::UnresolvedOperand> asyncOperandOperand; ::mlir::Type asyncOperandType; auto odsResult = parseOperandWithKeywordOnly(parser, asyncOperandOperand, asyncOperandType, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandOperand.has_value()) asyncOperandOperands.push_back(*asyncOperandOperand); if (asyncOperandType) asyncOperandTypes.push_back(asyncOperandType); if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("wait_devnum"))) { if (wait_devnumClause) { return parser.emitError(parser.getNameLoc()) << "`wait_devnum` clause can appear at most once in the expansion of the " "oilist directive"; } wait_devnumClause = true; if (parser.parseLParen()) return ::mlir::failure(); { waitDevnumOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); waitDevnumOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); waitDevnumTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("wait"))) { if (waitClause) { return parser.emitError(parser.getNameLoc()) << "`wait` clause can appear at most once in the expansion of the " "oilist directive"; } waitClause = true; { waitOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseOperandsWithKeywordOnly(parser, waitOperandsOperands, waitOperandsTypes, waitOnlyAttr); if (odsResult) return ::mlir::failure(); if (waitOnlyAttr) result.getOrAddProperties().waitOnly = waitOnlyAttr; } } else { break; } } if (parser.parseRegion(*regionRegion)) return ::mlir::failure(); if (regionRegion->empty()) regionRegion->emplaceBlock(); { 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.addRegion(std::move(regionRegion)); ::llvm::copy(::llvm::ArrayRef({static_cast(dataClauseOperandsOperands.size()), static_cast(asyncOperandOperands.size()), static_cast(waitDevnumOperands.size()), static_cast(waitOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); if (parser.resolveOperands(dataClauseOperandsOperands, dataClauseOperandsTypes, dataClauseOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (!asyncOperandOperands.empty()) { if (parser.resolveOperands(asyncOperandOperands, asyncOperandTypes, asyncOperandOperandsLoc, result.operands)) return ::mlir::failure(); } if (!waitDevnumOperands.empty()) { if (parser.resolveOperands(waitDevnumOperands, waitDevnumTypes, waitDevnumOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(waitOperandsOperands, waitOperandsTypes, waitOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void KernelEnvironmentOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getDataClauseOperands().size()) { _odsPrinter << ' ' << "dataOperands"; _odsPrinter << "("; _odsPrinter << getDataClauseOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getDataClauseOperands().getTypes(); _odsPrinter << ")"; } if (false || getAsyncOperand() || ((getAsyncOnlyAttr() && getAsyncOnlyAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) { _odsPrinter << ' ' << "async"; printOperandWithKeywordOnly(_odsPrinter, *this, getAsyncOperand(), (getAsyncOperand() ? getAsyncOperand().getType() : ::mlir::Type()), getAsyncOnlyAttr()); } if (false || getWaitDevnum()) { _odsPrinter << ' ' << "wait_devnum"; _odsPrinter << "("; if (::mlir::Value value = getWaitDevnum()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getWaitDevnum() ? ::llvm::ArrayRef<::mlir::Type>(getWaitDevnum().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getWaitOperands().size() || ((getWaitOnlyAttr() && getWaitOnlyAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) { _odsPrinter << ' ' << "wait"; printOperandsWithKeywordOnly(_odsPrinter, *this, getWaitOperands(), getWaitOperands().getTypes(), getWaitOnlyAttr()); } _odsPrinter << ' '; _odsPrinter.printRegion(getRegion()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("waitOnly"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getAsyncOnlyAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("asyncOnly"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getWaitOnlyAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("waitOnly"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } void KernelEnvironmentOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::acc::ConstructResource::get()); effects.emplace_back(::mlir::MemoryEffects::Read::get(), 0, false, ::mlir::acc::CurrentDeviceIdResource::get()); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::KernelEnvironmentOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::KernelEnvironmentOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::KernelsOp definitions //===----------------------------------------------------------------------===// namespace detail { KernelsOpGenericAdaptorBase::KernelsOpGenericAdaptorBase(KernelsOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair KernelsOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::std::optional< ::mlir::ArrayAttr > KernelsOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > KernelsOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> KernelsOpGenericAdaptorBase::getWaitOperandsSegments() { auto attr = getWaitOperandsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > KernelsOpGenericAdaptorBase::getWaitOperandsDeviceType() { auto attr = getWaitOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > KernelsOpGenericAdaptorBase::getHasWaitDevnum() { auto attr = getHasWaitDevnumAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > KernelsOpGenericAdaptorBase::getWaitOnly() { auto attr = getWaitOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> KernelsOpGenericAdaptorBase::getNumGangsSegments() { auto attr = getNumGangsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > KernelsOpGenericAdaptorBase::getNumGangsDeviceType() { auto attr = getNumGangsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > KernelsOpGenericAdaptorBase::getNumWorkersDeviceType() { auto attr = getNumWorkersDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > KernelsOpGenericAdaptorBase::getVectorLengthDeviceType() { auto attr = getVectorLengthDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::UnitAttr KernelsOpGenericAdaptorBase::getSelfAttrAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().selfAttr); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool KernelsOpGenericAdaptorBase::getSelfAttr() { auto attr = getSelfAttrAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::std::optional<::mlir::acc::ClauseDefaultValue> KernelsOpGenericAdaptorBase::getDefaultAttr() { auto attr = getDefaultAttrAttr(); return attr ? ::std::optional<::mlir::acc::ClauseDefaultValue>(attr.getValue()) : (::std::nullopt); } ::mlir::UnitAttr KernelsOpGenericAdaptorBase::getCombinedAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().combined); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool KernelsOpGenericAdaptorBase::getCombined() { auto attr = getCombinedAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail KernelsOpAdaptor::KernelsOpAdaptor(KernelsOp op) : KernelsOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult KernelsOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_combined = getProperties().combined; (void)tblgen_combined; auto tblgen_defaultAttr = getProperties().defaultAttr; (void)tblgen_defaultAttr; auto tblgen_hasWaitDevnum = getProperties().hasWaitDevnum; (void)tblgen_hasWaitDevnum; auto tblgen_numGangsDeviceType = getProperties().numGangsDeviceType; (void)tblgen_numGangsDeviceType; auto tblgen_numGangsSegments = getProperties().numGangsSegments; (void)tblgen_numGangsSegments; auto tblgen_numWorkersDeviceType = getProperties().numWorkersDeviceType; (void)tblgen_numWorkersDeviceType; auto tblgen_selfAttr = getProperties().selfAttr; (void)tblgen_selfAttr; auto tblgen_vectorLengthDeviceType = getProperties().vectorLengthDeviceType; (void)tblgen_vectorLengthDeviceType; auto tblgen_waitOnly = getProperties().waitOnly; (void)tblgen_waitOnly; auto tblgen_waitOperandsDeviceType = getProperties().waitOperandsDeviceType; (void)tblgen_waitOperandsDeviceType; auto tblgen_waitOperandsSegments = getProperties().waitOperandsSegments; (void)tblgen_waitOperandsSegments; if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.kernels' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.kernels' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_waitOperandsSegments && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_waitOperandsSegments)))) return emitError(loc, "'acc.kernels' op attribute 'waitOperandsSegments' failed to satisfy constraint: i32 dense array attribute"); if (tblgen_waitOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_waitOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_waitOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.kernels' op attribute 'waitOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_hasWaitDevnum && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_hasWaitDevnum))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_hasWaitDevnum), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::BoolAttr>(attr))); })))) return emitError(loc, "'acc.kernels' op attribute 'hasWaitDevnum' failed to satisfy constraint: 1-bit boolean array attribute"); if (tblgen_waitOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_waitOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_waitOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.kernels' op attribute 'waitOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_numGangsSegments && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_numGangsSegments)))) return emitError(loc, "'acc.kernels' op attribute 'numGangsSegments' failed to satisfy constraint: i32 dense array attribute"); if (tblgen_numGangsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_numGangsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_numGangsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.kernels' op attribute 'numGangsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_numWorkersDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_numWorkersDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_numWorkersDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.kernels' op attribute 'numWorkersDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_vectorLengthDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_vectorLengthDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_vectorLengthDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.kernels' op attribute 'vectorLengthDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_selfAttr && !((::llvm::isa<::mlir::UnitAttr>(tblgen_selfAttr)))) return emitError(loc, "'acc.kernels' op attribute 'selfAttr' failed to satisfy constraint: unit attribute"); if (tblgen_defaultAttr && !((::llvm::isa<::mlir::acc::ClauseDefaultValueAttr>(tblgen_defaultAttr)))) return emitError(loc, "'acc.kernels' op attribute 'defaultAttr' failed to satisfy constraint: DefaultValue Clause"); if (tblgen_combined && !((::llvm::isa<::mlir::UnitAttr>(tblgen_combined)))) return emitError(loc, "'acc.kernels' op attribute 'combined' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } std::pair KernelsOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange KernelsOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange KernelsOp::getWaitOperandsMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange KernelsOp::getNumGangsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange KernelsOp::getNumWorkersMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange KernelsOp::getVectorLengthMutable() { auto range = getODSOperandIndexAndLength(4); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(4u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange KernelsOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(5); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(5u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange KernelsOp::getSelfCondMutable() { auto range = getODSOperandIndexAndLength(6); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(6u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange KernelsOp::getReductionOperandsMutable() { auto range = getODSOperandIndexAndLength(7); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(7u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange KernelsOp::getPrivateOperandsMutable() { auto range = getODSOperandIndexAndLength(8); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(8u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange KernelsOp::getFirstprivateOperandsMutable() { auto range = getODSOperandIndexAndLength(9); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(9u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange KernelsOp::getDataClauseOperandsMutable() { auto range = getODSOperandIndexAndLength(10); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(10u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult KernelsOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.combined; auto attr = dict.get("combined"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `combined` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.defaultAttr; auto attr = dict.get("defaultAttr"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `defaultAttr` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.hasWaitDevnum; auto attr = dict.get("hasWaitDevnum"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `hasWaitDevnum` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.numGangsDeviceType; auto attr = dict.get("numGangsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `numGangsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.numGangsSegments; auto attr = dict.get("numGangsSegments"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `numGangsSegments` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.numWorkersDeviceType; auto attr = dict.get("numWorkersDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `numWorkersDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.selfAttr; auto attr = dict.get("selfAttr"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `selfAttr` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.vectorLengthDeviceType; auto attr = dict.get("vectorLengthDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `vectorLengthDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOnly; auto attr = dict.get("waitOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOperandsDeviceType; auto attr = dict.get("waitOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOperandsSegments; auto attr = dict.get("waitOperandsSegments"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOperandsSegments` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute KernelsOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.combined; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("combined", propStorage)); } { const auto &propStorage = prop.defaultAttr; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("defaultAttr", propStorage)); } { const auto &propStorage = prop.hasWaitDevnum; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("hasWaitDevnum", propStorage)); } { const auto &propStorage = prop.numGangsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("numGangsDeviceType", propStorage)); } { const auto &propStorage = prop.numGangsSegments; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("numGangsSegments", propStorage)); } { const auto &propStorage = prop.numWorkersDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("numWorkersDeviceType", propStorage)); } { const auto &propStorage = prop.selfAttr; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("selfAttr", propStorage)); } { const auto &propStorage = prop.vectorLengthDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("vectorLengthDeviceType", propStorage)); } { const auto &propStorage = prop.waitOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOnly", propStorage)); } { const auto &propStorage = prop.waitOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.waitOperandsSegments; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOperandsSegments", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code KernelsOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.combined.getAsOpaquePointer()), llvm::hash_value(prop.defaultAttr.getAsOpaquePointer()), llvm::hash_value(prop.hasWaitDevnum.getAsOpaquePointer()), llvm::hash_value(prop.numGangsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.numGangsSegments.getAsOpaquePointer()), llvm::hash_value(prop.numWorkersDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.selfAttr.getAsOpaquePointer()), llvm::hash_value(prop.vectorLengthDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.waitOnly.getAsOpaquePointer()), llvm::hash_value(prop.waitOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.waitOperandsSegments.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional KernelsOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "combined") return prop.combined; if (name == "defaultAttr") return prop.defaultAttr; if (name == "hasWaitDevnum") return prop.hasWaitDevnum; if (name == "numGangsDeviceType") return prop.numGangsDeviceType; if (name == "numGangsSegments") return prop.numGangsSegments; if (name == "numWorkersDeviceType") return prop.numWorkersDeviceType; if (name == "selfAttr") return prop.selfAttr; if (name == "vectorLengthDeviceType") return prop.vectorLengthDeviceType; if (name == "waitOnly") return prop.waitOnly; if (name == "waitOperandsDeviceType") return prop.waitOperandsDeviceType; if (name == "waitOperandsSegments") return prop.waitOperandsSegments; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void KernelsOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "combined") { prop.combined = ::llvm::dyn_cast_or_null>(value); return; } if (name == "defaultAttr") { prop.defaultAttr = ::llvm::dyn_cast_or_null>(value); return; } if (name == "hasWaitDevnum") { prop.hasWaitDevnum = ::llvm::dyn_cast_or_null>(value); return; } if (name == "numGangsDeviceType") { prop.numGangsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "numGangsSegments") { prop.numGangsSegments = ::llvm::dyn_cast_or_null>(value); return; } if (name == "numWorkersDeviceType") { prop.numWorkersDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "selfAttr") { prop.selfAttr = ::llvm::dyn_cast_or_null>(value); return; } if (name == "vectorLengthDeviceType") { prop.vectorLengthDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOnly") { prop.waitOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOperandsDeviceType") { prop.waitOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOperandsSegments") { prop.waitOperandsSegments = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void KernelsOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.combined) attrs.append("combined", prop.combined); if (prop.defaultAttr) attrs.append("defaultAttr", prop.defaultAttr); if (prop.hasWaitDevnum) attrs.append("hasWaitDevnum", prop.hasWaitDevnum); if (prop.numGangsDeviceType) attrs.append("numGangsDeviceType", prop.numGangsDeviceType); if (prop.numGangsSegments) attrs.append("numGangsSegments", prop.numGangsSegments); if (prop.numWorkersDeviceType) attrs.append("numWorkersDeviceType", prop.numWorkersDeviceType); if (prop.selfAttr) attrs.append("selfAttr", prop.selfAttr); if (prop.vectorLengthDeviceType) attrs.append("vectorLengthDeviceType", prop.vectorLengthDeviceType); if (prop.waitOnly) attrs.append("waitOnly", prop.waitOnly); if (prop.waitOperandsDeviceType) attrs.append("waitOperandsDeviceType", prop.waitOperandsDeviceType); if (prop.waitOperandsSegments) attrs.append("waitOperandsSegments", prop.waitOperandsSegments); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult KernelsOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCombinedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "combined", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDefaultAttrAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps11(attr, "defaultAttr", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getHasWaitDevnumAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps10(attr, "hasWaitDevnum", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNumGangsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "numGangsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNumGangsSegmentsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(attr, "numGangsSegments", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNumWorkersDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "numWorkersDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSelfAttrAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "selfAttr", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVectorLengthDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "vectorLengthDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "waitOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "waitOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOperandsSegmentsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(attr, "waitOperandsSegments", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult KernelsOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.combined))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.defaultAttr))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.hasWaitDevnum))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.numGangsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.numGangsSegments))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.numWorkersDeviceType))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.selfAttr))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.vectorLengthDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.waitOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.waitOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.waitOperandsSegments))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void KernelsOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.combined); writer.writeOptionalAttribute(prop.defaultAttr); writer.writeOptionalAttribute(prop.hasWaitDevnum); writer.writeOptionalAttribute(prop.numGangsDeviceType); writer.writeOptionalAttribute(prop.numGangsSegments); writer.writeOptionalAttribute(prop.numWorkersDeviceType); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.selfAttr); writer.writeOptionalAttribute(prop.vectorLengthDeviceType); writer.writeOptionalAttribute(prop.waitOnly); writer.writeOptionalAttribute(prop.waitOperandsDeviceType); writer.writeOptionalAttribute(prop.waitOperandsSegments); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::std::optional< ::mlir::ArrayAttr > KernelsOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > KernelsOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> KernelsOp::getWaitOperandsSegments() { auto attr = getWaitOperandsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > KernelsOp::getWaitOperandsDeviceType() { auto attr = getWaitOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > KernelsOp::getHasWaitDevnum() { auto attr = getHasWaitDevnumAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > KernelsOp::getWaitOnly() { auto attr = getWaitOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> KernelsOp::getNumGangsSegments() { auto attr = getNumGangsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > KernelsOp::getNumGangsDeviceType() { auto attr = getNumGangsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > KernelsOp::getNumWorkersDeviceType() { auto attr = getNumWorkersDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > KernelsOp::getVectorLengthDeviceType() { auto attr = getVectorLengthDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } bool KernelsOp::getSelfAttr() { auto attr = getSelfAttrAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::std::optional<::mlir::acc::ClauseDefaultValue> KernelsOp::getDefaultAttr() { auto attr = getDefaultAttrAttr(); return attr ? ::std::optional<::mlir::acc::ClauseDefaultValue>(attr.getValue()) : (::std::nullopt); } bool KernelsOp::getCombined() { auto attr = getCombinedAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void KernelsOp::setWaitOperandsSegments(::std::optional<::llvm::ArrayRef> attrValue) { auto &odsProp = getProperties().waitOperandsSegments; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(*attrValue); else odsProp = nullptr; } void KernelsOp::setNumGangsSegments(::std::optional<::llvm::ArrayRef> attrValue) { auto &odsProp = getProperties().numGangsSegments; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(*attrValue); else odsProp = nullptr; } void KernelsOp::setSelfAttr(bool attrValue) { auto &odsProp = getProperties().selfAttr; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void KernelsOp::setDefaultAttr(::std::optional<::mlir::acc::ClauseDefaultValue> attrValue) { auto &odsProp = getProperties().defaultAttr; if (attrValue) odsProp = ::mlir::acc::ClauseDefaultValueAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void KernelsOp::setCombined(bool attrValue) { auto &odsProp = getProperties().combined; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void KernelsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); odsState.addOperands(numGangs); odsState.addOperands(numWorkers); odsState.addOperands(vectorLength); if (ifCond) odsState.addOperands(ifCond); if (selfCond) odsState.addOperands(selfCond); odsState.addOperands(reductionOperands); odsState.addOperands(privateOperands); odsState.addOperands(firstprivateOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(asyncOperands.size()), static_cast(waitOperands.size()), static_cast(numGangs.size()), static_cast(numWorkers.size()), static_cast(vectorLength.size()), (ifCond ? 1 : 0), (selfCond ? 1 : 0), static_cast(reductionOperands.size()), static_cast(privateOperands.size()), static_cast(firstprivateOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (numGangsSegments) { odsState.getOrAddProperties().numGangsSegments = numGangsSegments; } if (numGangsDeviceType) { odsState.getOrAddProperties().numGangsDeviceType = numGangsDeviceType; } if (numWorkersDeviceType) { odsState.getOrAddProperties().numWorkersDeviceType = numWorkersDeviceType; } if (vectorLengthDeviceType) { odsState.getOrAddProperties().vectorLengthDeviceType = vectorLengthDeviceType; } if (selfAttr) { odsState.getOrAddProperties().selfAttr = selfAttr; } if (defaultAttr) { odsState.getOrAddProperties().defaultAttr = defaultAttr; } if (combined) { odsState.getOrAddProperties().combined = combined; } (void)odsState.addRegion(); } KernelsOp KernelsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } KernelsOp KernelsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { return create(builder, builder.getLoc(), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); } void KernelsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); odsState.addOperands(numGangs); odsState.addOperands(numWorkers); odsState.addOperands(vectorLength); if (ifCond) odsState.addOperands(ifCond); if (selfCond) odsState.addOperands(selfCond); odsState.addOperands(reductionOperands); odsState.addOperands(privateOperands); odsState.addOperands(firstprivateOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(asyncOperands.size()), static_cast(waitOperands.size()), static_cast(numGangs.size()), static_cast(numWorkers.size()), static_cast(vectorLength.size()), (ifCond ? 1 : 0), (selfCond ? 1 : 0), static_cast(reductionOperands.size()), static_cast(privateOperands.size()), static_cast(firstprivateOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (numGangsSegments) { odsState.getOrAddProperties().numGangsSegments = numGangsSegments; } if (numGangsDeviceType) { odsState.getOrAddProperties().numGangsDeviceType = numGangsDeviceType; } if (numWorkersDeviceType) { odsState.getOrAddProperties().numWorkersDeviceType = numWorkersDeviceType; } if (vectorLengthDeviceType) { odsState.getOrAddProperties().vectorLengthDeviceType = vectorLengthDeviceType; } if (selfAttr) { odsState.getOrAddProperties().selfAttr = selfAttr; } if (defaultAttr) { odsState.getOrAddProperties().defaultAttr = defaultAttr; } if (combined) { odsState.getOrAddProperties().combined = combined; } (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } KernelsOp KernelsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } KernelsOp KernelsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); } void KernelsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); odsState.addOperands(numGangs); odsState.addOperands(numWorkers); odsState.addOperands(vectorLength); if (ifCond) odsState.addOperands(ifCond); if (selfCond) odsState.addOperands(selfCond); odsState.addOperands(reductionOperands); odsState.addOperands(privateOperands); odsState.addOperands(firstprivateOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(asyncOperands.size()), static_cast(waitOperands.size()), static_cast(numGangs.size()), static_cast(numWorkers.size()), static_cast(vectorLength.size()), (ifCond ? 1 : 0), (selfCond ? 1 : 0), static_cast(reductionOperands.size()), static_cast(privateOperands.size()), static_cast(firstprivateOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (numGangsSegments) { odsState.getOrAddProperties().numGangsSegments = numGangsSegments; } if (numGangsDeviceType) { odsState.getOrAddProperties().numGangsDeviceType = numGangsDeviceType; } if (numWorkersDeviceType) { odsState.getOrAddProperties().numWorkersDeviceType = numWorkersDeviceType; } if (vectorLengthDeviceType) { odsState.getOrAddProperties().vectorLengthDeviceType = vectorLengthDeviceType; } if (selfAttr) { odsState.getOrAddProperties().selfAttr = ((selfAttr) ? odsBuilder.getUnitAttr() : nullptr); } if (defaultAttr) { odsState.getOrAddProperties().defaultAttr = defaultAttr; } if (combined) { odsState.getOrAddProperties().combined = ((combined) ? odsBuilder.getUnitAttr() : nullptr); } (void)odsState.addRegion(); } KernelsOp KernelsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } KernelsOp KernelsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { return create(builder, builder.getLoc(), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); } void KernelsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); odsState.addOperands(numGangs); odsState.addOperands(numWorkers); odsState.addOperands(vectorLength); if (ifCond) odsState.addOperands(ifCond); if (selfCond) odsState.addOperands(selfCond); odsState.addOperands(reductionOperands); odsState.addOperands(privateOperands); odsState.addOperands(firstprivateOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(asyncOperands.size()), static_cast(waitOperands.size()), static_cast(numGangs.size()), static_cast(numWorkers.size()), static_cast(vectorLength.size()), (ifCond ? 1 : 0), (selfCond ? 1 : 0), static_cast(reductionOperands.size()), static_cast(privateOperands.size()), static_cast(firstprivateOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (numGangsSegments) { odsState.getOrAddProperties().numGangsSegments = numGangsSegments; } if (numGangsDeviceType) { odsState.getOrAddProperties().numGangsDeviceType = numGangsDeviceType; } if (numWorkersDeviceType) { odsState.getOrAddProperties().numWorkersDeviceType = numWorkersDeviceType; } if (vectorLengthDeviceType) { odsState.getOrAddProperties().vectorLengthDeviceType = vectorLengthDeviceType; } if (selfAttr) { odsState.getOrAddProperties().selfAttr = ((selfAttr) ? odsBuilder.getUnitAttr() : nullptr); } if (defaultAttr) { odsState.getOrAddProperties().defaultAttr = defaultAttr; } if (combined) { odsState.getOrAddProperties().combined = ((combined) ? odsBuilder.getUnitAttr() : nullptr); } (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } KernelsOp KernelsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } KernelsOp KernelsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); } void KernelsOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } KernelsOp KernelsOp::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__; } KernelsOp KernelsOp::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 KernelsOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } KernelsOp KernelsOp::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__; } KernelsOp KernelsOp::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 KernelsOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_combined = getProperties().combined; (void)tblgen_combined; auto tblgen_defaultAttr = getProperties().defaultAttr; (void)tblgen_defaultAttr; auto tblgen_hasWaitDevnum = getProperties().hasWaitDevnum; (void)tblgen_hasWaitDevnum; auto tblgen_numGangsDeviceType = getProperties().numGangsDeviceType; (void)tblgen_numGangsDeviceType; auto tblgen_numGangsSegments = getProperties().numGangsSegments; (void)tblgen_numGangsSegments; auto tblgen_numWorkersDeviceType = getProperties().numWorkersDeviceType; (void)tblgen_numWorkersDeviceType; auto tblgen_selfAttr = getProperties().selfAttr; (void)tblgen_selfAttr; auto tblgen_vectorLengthDeviceType = getProperties().vectorLengthDeviceType; (void)tblgen_vectorLengthDeviceType; auto tblgen_waitOnly = getProperties().waitOnly; (void)tblgen_waitOnly; auto tblgen_waitOperandsDeviceType = getProperties().waitOperandsDeviceType; (void)tblgen_waitOperandsDeviceType; auto tblgen_waitOperandsSegments = getProperties().waitOperandsSegments; (void)tblgen_waitOperandsSegments; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(*this, tblgen_waitOperandsSegments, "waitOperandsSegments"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_waitOperandsDeviceType, "waitOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps10(*this, tblgen_hasWaitDevnum, "hasWaitDevnum"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_waitOnly, "waitOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(*this, tblgen_numGangsSegments, "numGangsSegments"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_numGangsDeviceType, "numGangsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_numWorkersDeviceType, "numWorkersDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_vectorLengthDeviceType, "vectorLengthDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_selfAttr, "selfAttr"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps11(*this, tblgen_defaultAttr, "defaultAttr"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_combined, "combined"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup5 = getODSOperands(5); if (valueGroup5.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup5.size(); } for (auto v : valueGroup5) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup6 = getODSOperands(6); if (valueGroup6.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup6.size(); } for (auto v : valueGroup6) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup7 = getODSOperands(7); for (auto v : valueGroup7) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup8 = getODSOperands(8); for (auto v : valueGroup8) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup9 = getODSOperands(9); for (auto v : valueGroup9) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup10 = getODSOperands(10); for (auto v : valueGroup10) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult KernelsOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult KernelsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dataClauseOperandsOperands; ::llvm::SMLoc dataClauseOperandsOperandsLoc; (void)dataClauseOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> dataClauseOperandsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> firstprivateOperandsOperands; ::llvm::SMLoc firstprivateOperandsOperandsLoc; (void)firstprivateOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> firstprivateOperandsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> numGangsOperands; ::llvm::SMLoc numGangsOperandsLoc; (void)numGangsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> numGangsTypes; ::mlir::ArrayAttr numGangsDeviceTypeAttr; ::mlir::DenseI32ArrayAttr numGangsSegmentsAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> numWorkersOperands; ::llvm::SMLoc numWorkersOperandsLoc; (void)numWorkersOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> numWorkersTypes; ::mlir::ArrayAttr numWorkersDeviceTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> privateOperandsOperands; ::llvm::SMLoc privateOperandsOperandsLoc; (void)privateOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> privateOperandsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> vectorLengthOperands; ::llvm::SMLoc vectorLengthOperandsLoc; (void)vectorLengthOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> vectorLengthTypes; ::mlir::ArrayAttr vectorLengthDeviceTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> waitOperandsOperands; ::llvm::SMLoc waitOperandsOperandsLoc; (void)waitOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> waitOperandsTypes; ::mlir::ArrayAttr waitOperandsDeviceTypeAttr; ::mlir::DenseI32ArrayAttr waitOperandsSegmentsAttr; ::mlir::ArrayAttr hasWaitDevnumAttr; ::mlir::ArrayAttr waitOnlyAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> selfCondOperands; ::llvm::SMLoc selfCondOperandsLoc; (void)selfCondOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> reductionOperandsOperands; ::llvm::SMLoc reductionOperandsOperandsLoc; (void)reductionOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> reductionOperandsTypes; std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); if (::mlir::succeeded(parser.parseOptionalKeyword("combined"))) { result.getOrAddProperties().combined = parser.getBuilder().getUnitAttr(); if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseKeyword("loop")) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } bool dataOperandsClause = false; bool asyncClause = false; bool firstprivateClause = false; bool num_gangsClause = false; bool num_workersClause = false; bool privateClause = false; bool vector_lengthClause = false; bool waitClause = false; bool selfClause = false; bool ifClause = false; bool reductionClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("dataOperands"))) { if (dataOperandsClause) { return parser.emitError(parser.getNameLoc()) << "`dataOperands` clause can appear at most once in the expansion of the " "oilist directive"; } dataOperandsClause = true; if (parser.parseLParen()) return ::mlir::failure(); dataClauseOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(dataClauseOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(dataClauseOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("firstprivate"))) { if (firstprivateClause) { return parser.emitError(parser.getNameLoc()) << "`firstprivate` clause can appear at most once in the expansion of the " "oilist directive"; } firstprivateClause = true; if (parser.parseLParen()) return ::mlir::failure(); firstprivateOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(firstprivateOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(firstprivateOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("num_gangs"))) { if (num_gangsClause) { return parser.emitError(parser.getNameLoc()) << "`num_gangs` clause can appear at most once in the expansion of the " "oilist directive"; } num_gangsClause = true; if (parser.parseLParen()) return ::mlir::failure(); { numGangsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseNumGangs(parser, numGangsOperands, numGangsTypes, numGangsDeviceTypeAttr, numGangsSegmentsAttr); if (odsResult) return ::mlir::failure(); if (numGangsDeviceTypeAttr) result.getOrAddProperties().numGangsDeviceType = numGangsDeviceTypeAttr; if (numGangsSegmentsAttr) result.getOrAddProperties().numGangsSegments = numGangsSegmentsAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("num_workers"))) { if (num_workersClause) { return parser.emitError(parser.getNameLoc()) << "`num_workers` clause can appear at most once in the expansion of the " "oilist directive"; } num_workersClause = true; if (parser.parseLParen()) return ::mlir::failure(); { numWorkersOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperands(parser, numWorkersOperands, numWorkersTypes, numWorkersDeviceTypeAttr); if (odsResult) return ::mlir::failure(); if (numWorkersDeviceTypeAttr) result.getOrAddProperties().numWorkersDeviceType = numWorkersDeviceTypeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("private"))) { if (privateClause) { return parser.emitError(parser.getNameLoc()) << "`private` clause can appear at most once in the expansion of the " "oilist directive"; } privateClause = true; if (parser.parseLParen()) return ::mlir::failure(); privateOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(privateOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(privateOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("vector_length"))) { if (vector_lengthClause) { return parser.emitError(parser.getNameLoc()) << "`vector_length` clause can appear at most once in the expansion of the " "oilist directive"; } vector_lengthClause = true; if (parser.parseLParen()) return ::mlir::failure(); { vectorLengthOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperands(parser, vectorLengthOperands, vectorLengthTypes, vectorLengthDeviceTypeAttr); if (odsResult) return ::mlir::failure(); if (vectorLengthDeviceTypeAttr) result.getOrAddProperties().vectorLengthDeviceType = vectorLengthDeviceTypeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("wait"))) { if (waitClause) { return parser.emitError(parser.getNameLoc()) << "`wait` clause can appear at most once in the expansion of the " "oilist directive"; } waitClause = true; { waitOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseWaitClause(parser, waitOperandsOperands, waitOperandsTypes, waitOperandsDeviceTypeAttr, waitOperandsSegmentsAttr, hasWaitDevnumAttr, waitOnlyAttr); if (odsResult) return ::mlir::failure(); if (waitOperandsDeviceTypeAttr) result.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceTypeAttr; if (waitOperandsSegmentsAttr) result.getOrAddProperties().waitOperandsSegments = waitOperandsSegmentsAttr; if (hasWaitDevnumAttr) result.getOrAddProperties().hasWaitDevnum = hasWaitDevnumAttr; if (waitOnlyAttr) result.getOrAddProperties().waitOnly = waitOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("self"))) { if (selfClause) { return parser.emitError(parser.getNameLoc()) << "`self` clause can appear at most once in the expansion of the " "oilist directive"; } selfClause = true; if (parser.parseLParen()) return ::mlir::failure(); { selfCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); selfCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("reduction"))) { if (reductionClause) { return parser.emitError(parser.getNameLoc()) << "`reduction` clause can appear at most once in the expansion of the " "oilist directive"; } reductionClause = true; if (parser.parseLParen()) return ::mlir::failure(); reductionOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(reductionOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(reductionOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseRegion(*regionRegion)) return ::mlir::failure(); { 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(); } result.addRegion(std::move(regionRegion)); ::llvm::copy(::llvm::ArrayRef({static_cast(asyncOperandsOperands.size()), static_cast(waitOperandsOperands.size()), static_cast(numGangsOperands.size()), static_cast(numWorkersOperands.size()), static_cast(vectorLengthOperands.size()), static_cast(ifCondOperands.size()), static_cast(selfCondOperands.size()), static_cast(reductionOperandsOperands.size()), static_cast(privateOperandsOperands.size()), static_cast(firstprivateOperandsOperands.size()), static_cast(dataClauseOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(waitOperandsOperands, waitOperandsTypes, waitOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(numGangsOperands, numGangsTypes, numGangsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(numWorkersOperands, numWorkersTypes, numWorkersOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(vectorLengthOperands, vectorLengthTypes, vectorLengthOperandsLoc, result.operands)) return ::mlir::failure(); if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } if (!selfCondOperands.empty()) { if (parser.resolveOperands(selfCondOperands, odsBuildableType0, selfCondOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(reductionOperandsOperands, reductionOperandsTypes, reductionOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(privateOperandsOperands, privateOperandsTypes, privateOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(firstprivateOperandsOperands, firstprivateOperandsTypes, firstprivateOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(dataClauseOperandsOperands, dataClauseOperandsTypes, dataClauseOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void KernelsOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if ((getCombinedAttr() && getCombinedAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "combined"; _odsPrinter << "("; _odsPrinter << "loop"; _odsPrinter << ")"; } if (false || getDataClauseOperands().size()) { _odsPrinter << ' ' << "dataOperands"; _odsPrinter << "("; _odsPrinter << getDataClauseOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getDataClauseOperands().getTypes(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || getFirstprivateOperands().size()) { _odsPrinter << ' ' << "firstprivate"; _odsPrinter << "("; _odsPrinter << getFirstprivateOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getFirstprivateOperands().getTypes(); _odsPrinter << ")"; } if (false || getNumGangs().size() || (getNumGangsDeviceTypeAttr()) || (getNumGangsSegmentsAttr())) { _odsPrinter << ' ' << "num_gangs"; _odsPrinter << "("; printNumGangs(_odsPrinter, *this, getNumGangs(), getNumGangs().getTypes(), getNumGangsDeviceTypeAttr(), getNumGangsSegmentsAttr()); _odsPrinter << ")"; } if (false || getNumWorkers().size() || (getNumWorkersDeviceTypeAttr())) { _odsPrinter << ' ' << "num_workers"; _odsPrinter << "("; printDeviceTypeOperands(_odsPrinter, *this, getNumWorkers(), getNumWorkers().getTypes(), getNumWorkersDeviceTypeAttr()); _odsPrinter << ")"; } if (false || getPrivateOperands().size()) { _odsPrinter << ' ' << "private"; _odsPrinter << "("; _odsPrinter << getPrivateOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getPrivateOperands().getTypes(); _odsPrinter << ")"; } if (false || getVectorLength().size() || (getVectorLengthDeviceTypeAttr())) { _odsPrinter << ' ' << "vector_length"; _odsPrinter << "("; printDeviceTypeOperands(_odsPrinter, *this, getVectorLength(), getVectorLength().getTypes(), getVectorLengthDeviceTypeAttr()); _odsPrinter << ")"; } if (false || getWaitOperands().size() || (getWaitOperandsDeviceTypeAttr()) || (getWaitOperandsSegmentsAttr()) || (getHasWaitDevnumAttr()) || (getWaitOnlyAttr())) { _odsPrinter << ' ' << "wait"; printWaitClause(_odsPrinter, *this, getWaitOperands(), getWaitOperands().getTypes(), getWaitOperandsDeviceTypeAttr(), getWaitOperandsSegmentsAttr(), getHasWaitDevnumAttr(), getWaitOnlyAttr()); } if (false || getSelfCond()) { _odsPrinter << ' ' << "self"; _odsPrinter << "("; if (::mlir::Value value = getSelfCond()) _odsPrinter << value; _odsPrinter << ")"; } if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } if (false || getReductionOperands().size()) { _odsPrinter << ' ' << "reduction"; _odsPrinter << "("; _odsPrinter << getReductionOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getReductionOperands().getTypes(); _odsPrinter << ")"; } _odsPrinter << ' '; _odsPrinter.printRegion(getRegion()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("combined"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("numGangsDeviceType"); elidedAttrs.push_back("numGangsSegments"); elidedAttrs.push_back("numWorkersDeviceType"); elidedAttrs.push_back("vectorLengthDeviceType"); elidedAttrs.push_back("waitOperandsDeviceType"); elidedAttrs.push_back("waitOperandsSegments"); elidedAttrs.push_back("hasWaitDevnum"); elidedAttrs.push_back("waitOnly"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getSelfAttrAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("selfAttr"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getCombinedAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("combined"); } _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } void KernelsOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::acc::ConstructResource::get()); effects.emplace_back(::mlir::MemoryEffects::Read::get(), 0, false, ::mlir::acc::CurrentDeviceIdResource::get()); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::KernelsOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::KernelsOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::LoopOp definitions //===----------------------------------------------------------------------===// namespace detail { LoopOpGenericAdaptorBase::LoopOpGenericAdaptorBase(LoopOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair LoopOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::std::optional<::llvm::ArrayRef> LoopOpGenericAdaptorBase::getInclusiveUpperbound() { auto attr = getInclusiveUpperboundAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOpGenericAdaptorBase::getCollapse() { auto attr = getCollapseAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOpGenericAdaptorBase::getCollapseDeviceType() { auto attr = getCollapseDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOpGenericAdaptorBase::getGangOperandsArgType() { auto attr = getGangOperandsArgTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> LoopOpGenericAdaptorBase::getGangOperandsSegments() { auto attr = getGangOperandsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOpGenericAdaptorBase::getGangOperandsDeviceType() { auto attr = getGangOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOpGenericAdaptorBase::getWorkerNumOperandsDeviceType() { auto attr = getWorkerNumOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOpGenericAdaptorBase::getVectorOperandsDeviceType() { auto attr = getVectorOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOpGenericAdaptorBase::getSeq() { auto attr = getSeqAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOpGenericAdaptorBase::getIndependent() { auto attr = getIndependentAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOpGenericAdaptorBase::getAuto_() { auto attr = getAuto_Attr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOpGenericAdaptorBase::getGang() { auto attr = getGangAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOpGenericAdaptorBase::getWorker() { auto attr = getWorkerAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOpGenericAdaptorBase::getVector() { auto attr = getVectorAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> LoopOpGenericAdaptorBase::getTileOperandsSegments() { auto attr = getTileOperandsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOpGenericAdaptorBase::getTileOperandsDeviceType() { auto attr = getTileOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::mlir::acc::CombinedConstructsType> LoopOpGenericAdaptorBase::getCombined() { auto attr = getCombinedAttr(); return attr ? ::std::optional<::mlir::acc::CombinedConstructsType>(attr.getValue()) : (::std::nullopt); } ::mlir::UnitAttr LoopOpGenericAdaptorBase::getUnstructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().unstructured); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool LoopOpGenericAdaptorBase::getUnstructured() { auto attr = getUnstructuredAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail LoopOpAdaptor::LoopOpAdaptor(LoopOp op) : LoopOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult LoopOpAdaptor::verify(::mlir::Location loc) { auto tblgen_auto_ = getProperties().auto_; (void)tblgen_auto_; auto tblgen_collapse = getProperties().collapse; (void)tblgen_collapse; auto tblgen_collapseDeviceType = getProperties().collapseDeviceType; (void)tblgen_collapseDeviceType; auto tblgen_combined = getProperties().combined; (void)tblgen_combined; auto tblgen_gang = getProperties().gang; (void)tblgen_gang; auto tblgen_gangOperandsArgType = getProperties().gangOperandsArgType; (void)tblgen_gangOperandsArgType; auto tblgen_gangOperandsDeviceType = getProperties().gangOperandsDeviceType; (void)tblgen_gangOperandsDeviceType; auto tblgen_gangOperandsSegments = getProperties().gangOperandsSegments; (void)tblgen_gangOperandsSegments; auto tblgen_inclusiveUpperbound = getProperties().inclusiveUpperbound; (void)tblgen_inclusiveUpperbound; auto tblgen_independent = getProperties().independent; (void)tblgen_independent; auto tblgen_seq = getProperties().seq; (void)tblgen_seq; auto tblgen_tileOperandsDeviceType = getProperties().tileOperandsDeviceType; (void)tblgen_tileOperandsDeviceType; auto tblgen_tileOperandsSegments = getProperties().tileOperandsSegments; (void)tblgen_tileOperandsSegments; auto tblgen_unstructured = getProperties().unstructured; (void)tblgen_unstructured; auto tblgen_vector = getProperties().vector; (void)tblgen_vector; auto tblgen_vectorOperandsDeviceType = getProperties().vectorOperandsDeviceType; (void)tblgen_vectorOperandsDeviceType; auto tblgen_worker = getProperties().worker; (void)tblgen_worker; auto tblgen_workerNumOperandsDeviceType = getProperties().workerNumOperandsDeviceType; (void)tblgen_workerNumOperandsDeviceType; if (tblgen_inclusiveUpperbound && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(tblgen_inclusiveUpperbound)))) return emitError(loc, "'acc.loop' op attribute 'inclusiveUpperbound' failed to satisfy constraint: i1 dense array attribute"); if (tblgen_collapse && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_collapse))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_collapse), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); })))) return emitError(loc, "'acc.loop' op attribute 'collapse' failed to satisfy constraint: 64-bit integer array attribute"); if (tblgen_collapseDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_collapseDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_collapseDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.loop' op attribute 'collapseDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_gangOperandsArgType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_gangOperandsArgType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_gangOperandsArgType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::GangArgTypeAttr>(attr))); })))) return emitError(loc, "'acc.loop' op attribute 'gangOperandsArgType' failed to satisfy constraint: gang arg type array attribute"); if (tblgen_gangOperandsSegments && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_gangOperandsSegments)))) return emitError(loc, "'acc.loop' op attribute 'gangOperandsSegments' failed to satisfy constraint: i32 dense array attribute"); if (tblgen_gangOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_gangOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_gangOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.loop' op attribute 'gangOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_workerNumOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_workerNumOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_workerNumOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.loop' op attribute 'workerNumOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_vectorOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_vectorOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_vectorOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.loop' op attribute 'vectorOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_seq && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_seq))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_seq), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.loop' op attribute 'seq' failed to satisfy constraint: device type array attribute"); if (tblgen_independent && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_independent))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_independent), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.loop' op attribute 'independent' failed to satisfy constraint: device type array attribute"); if (tblgen_auto_ && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_auto_))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_auto_), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.loop' op attribute 'auto_' failed to satisfy constraint: device type array attribute"); if (tblgen_gang && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_gang))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_gang), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.loop' op attribute 'gang' failed to satisfy constraint: device type array attribute"); if (tblgen_worker && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_worker))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_worker), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.loop' op attribute 'worker' failed to satisfy constraint: device type array attribute"); if (tblgen_vector && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_vector))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_vector), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.loop' op attribute 'vector' failed to satisfy constraint: device type array attribute"); if (tblgen_tileOperandsSegments && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_tileOperandsSegments)))) return emitError(loc, "'acc.loop' op attribute 'tileOperandsSegments' failed to satisfy constraint: i32 dense array attribute"); if (tblgen_tileOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_tileOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_tileOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.loop' op attribute 'tileOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_combined && !((::llvm::isa<::mlir::acc::CombinedConstructsTypeAttr>(tblgen_combined)))) return emitError(loc, "'acc.loop' op attribute 'combined' failed to satisfy constraint: Differentiate between combined constructs"); if (tblgen_unstructured && !((::llvm::isa<::mlir::UnitAttr>(tblgen_unstructured)))) return emitError(loc, "'acc.loop' op attribute 'unstructured' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } std::pair LoopOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange LoopOp::getLowerboundMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange LoopOp::getUpperboundMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange LoopOp::getStepMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange LoopOp::getGangOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange LoopOp::getWorkerNumOperandsMutable() { auto range = getODSOperandIndexAndLength(4); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(4u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange LoopOp::getVectorOperandsMutable() { auto range = getODSOperandIndexAndLength(5); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(5u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange LoopOp::getTileOperandsMutable() { auto range = getODSOperandIndexAndLength(6); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(6u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange LoopOp::getCacheOperandsMutable() { auto range = getODSOperandIndexAndLength(7); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(7u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange LoopOp::getPrivateOperandsMutable() { auto range = getODSOperandIndexAndLength(8); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(8u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange LoopOp::getFirstprivateOperandsMutable() { auto range = getODSOperandIndexAndLength(9); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(9u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange LoopOp::getReductionOperandsMutable() { auto range = getODSOperandIndexAndLength(10); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(10u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } std::pair LoopOp::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 LoopOp::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.auto_; auto attr = dict.get("auto_"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `auto_` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.collapse; auto attr = dict.get("collapse"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `collapse` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.collapseDeviceType; auto attr = dict.get("collapseDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `collapseDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.combined; auto attr = dict.get("combined"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `combined` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.gang; auto attr = dict.get("gang"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `gang` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.gangOperandsArgType; auto attr = dict.get("gangOperandsArgType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `gangOperandsArgType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.gangOperandsDeviceType; auto attr = dict.get("gangOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `gangOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.gangOperandsSegments; auto attr = dict.get("gangOperandsSegments"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `gangOperandsSegments` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.inclusiveUpperbound; auto attr = dict.get("inclusiveUpperbound"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `inclusiveUpperbound` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.independent; auto attr = dict.get("independent"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `independent` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.seq; auto attr = dict.get("seq"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `seq` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.tileOperandsDeviceType; auto attr = dict.get("tileOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `tileOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.tileOperandsSegments; auto attr = dict.get("tileOperandsSegments"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `tileOperandsSegments` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.unstructured; auto attr = dict.get("unstructured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `unstructured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.vector; auto attr = dict.get("vector"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `vector` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.vectorOperandsDeviceType; auto attr = dict.get("vectorOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `vectorOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.worker; auto attr = dict.get("worker"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `worker` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.workerNumOperandsDeviceType; auto attr = dict.get("workerNumOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `workerNumOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute LoopOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.auto_; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("auto_", propStorage)); } { const auto &propStorage = prop.collapse; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("collapse", propStorage)); } { const auto &propStorage = prop.collapseDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("collapseDeviceType", propStorage)); } { const auto &propStorage = prop.combined; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("combined", propStorage)); } { const auto &propStorage = prop.gang; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("gang", propStorage)); } { const auto &propStorage = prop.gangOperandsArgType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("gangOperandsArgType", propStorage)); } { const auto &propStorage = prop.gangOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("gangOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.gangOperandsSegments; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("gangOperandsSegments", propStorage)); } { const auto &propStorage = prop.inclusiveUpperbound; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("inclusiveUpperbound", propStorage)); } { const auto &propStorage = prop.independent; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("independent", propStorage)); } { const auto &propStorage = prop.seq; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("seq", propStorage)); } { const auto &propStorage = prop.tileOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("tileOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.tileOperandsSegments; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("tileOperandsSegments", propStorage)); } { const auto &propStorage = prop.unstructured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("unstructured", propStorage)); } { const auto &propStorage = prop.vector; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("vector", propStorage)); } { const auto &propStorage = prop.vectorOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("vectorOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.worker; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("worker", propStorage)); } { const auto &propStorage = prop.workerNumOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("workerNumOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code LoopOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.auto_.getAsOpaquePointer()), llvm::hash_value(prop.collapse.getAsOpaquePointer()), llvm::hash_value(prop.collapseDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.combined.getAsOpaquePointer()), llvm::hash_value(prop.gang.getAsOpaquePointer()), llvm::hash_value(prop.gangOperandsArgType.getAsOpaquePointer()), llvm::hash_value(prop.gangOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.gangOperandsSegments.getAsOpaquePointer()), llvm::hash_value(prop.inclusiveUpperbound.getAsOpaquePointer()), llvm::hash_value(prop.independent.getAsOpaquePointer()), llvm::hash_value(prop.seq.getAsOpaquePointer()), llvm::hash_value(prop.tileOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.tileOperandsSegments.getAsOpaquePointer()), llvm::hash_value(prop.unstructured.getAsOpaquePointer()), llvm::hash_value(prop.vector.getAsOpaquePointer()), llvm::hash_value(prop.vectorOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.worker.getAsOpaquePointer()), llvm::hash_value(prop.workerNumOperandsDeviceType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional LoopOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "auto_") return prop.auto_; if (name == "collapse") return prop.collapse; if (name == "collapseDeviceType") return prop.collapseDeviceType; if (name == "combined") return prop.combined; if (name == "gang") return prop.gang; if (name == "gangOperandsArgType") return prop.gangOperandsArgType; if (name == "gangOperandsDeviceType") return prop.gangOperandsDeviceType; if (name == "gangOperandsSegments") return prop.gangOperandsSegments; if (name == "inclusiveUpperbound") return prop.inclusiveUpperbound; if (name == "independent") return prop.independent; if (name == "seq") return prop.seq; if (name == "tileOperandsDeviceType") return prop.tileOperandsDeviceType; if (name == "tileOperandsSegments") return prop.tileOperandsSegments; if (name == "unstructured") return prop.unstructured; if (name == "vector") return prop.vector; if (name == "vectorOperandsDeviceType") return prop.vectorOperandsDeviceType; if (name == "worker") return prop.worker; if (name == "workerNumOperandsDeviceType") return prop.workerNumOperandsDeviceType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void LoopOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "auto_") { prop.auto_ = ::llvm::dyn_cast_or_null>(value); return; } if (name == "collapse") { prop.collapse = ::llvm::dyn_cast_or_null>(value); return; } if (name == "collapseDeviceType") { prop.collapseDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "combined") { prop.combined = ::llvm::dyn_cast_or_null>(value); return; } if (name == "gang") { prop.gang = ::llvm::dyn_cast_or_null>(value); return; } if (name == "gangOperandsArgType") { prop.gangOperandsArgType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "gangOperandsDeviceType") { prop.gangOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "gangOperandsSegments") { prop.gangOperandsSegments = ::llvm::dyn_cast_or_null>(value); return; } if (name == "inclusiveUpperbound") { prop.inclusiveUpperbound = ::llvm::dyn_cast_or_null>(value); return; } if (name == "independent") { prop.independent = ::llvm::dyn_cast_or_null>(value); return; } if (name == "seq") { prop.seq = ::llvm::dyn_cast_or_null>(value); return; } if (name == "tileOperandsDeviceType") { prop.tileOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "tileOperandsSegments") { prop.tileOperandsSegments = ::llvm::dyn_cast_or_null>(value); return; } if (name == "unstructured") { prop.unstructured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "vector") { prop.vector = ::llvm::dyn_cast_or_null>(value); return; } if (name == "vectorOperandsDeviceType") { prop.vectorOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "worker") { prop.worker = ::llvm::dyn_cast_or_null>(value); return; } if (name == "workerNumOperandsDeviceType") { prop.workerNumOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void LoopOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.auto_) attrs.append("auto_", prop.auto_); if (prop.collapse) attrs.append("collapse", prop.collapse); if (prop.collapseDeviceType) attrs.append("collapseDeviceType", prop.collapseDeviceType); if (prop.combined) attrs.append("combined", prop.combined); if (prop.gang) attrs.append("gang", prop.gang); if (prop.gangOperandsArgType) attrs.append("gangOperandsArgType", prop.gangOperandsArgType); if (prop.gangOperandsDeviceType) attrs.append("gangOperandsDeviceType", prop.gangOperandsDeviceType); if (prop.gangOperandsSegments) attrs.append("gangOperandsSegments", prop.gangOperandsSegments); if (prop.inclusiveUpperbound) attrs.append("inclusiveUpperbound", prop.inclusiveUpperbound); if (prop.independent) attrs.append("independent", prop.independent); if (prop.seq) attrs.append("seq", prop.seq); if (prop.tileOperandsDeviceType) attrs.append("tileOperandsDeviceType", prop.tileOperandsDeviceType); if (prop.tileOperandsSegments) attrs.append("tileOperandsSegments", prop.tileOperandsSegments); if (prop.unstructured) attrs.append("unstructured", prop.unstructured); if (prop.vector) attrs.append("vector", prop.vector); if (prop.vectorOperandsDeviceType) attrs.append("vectorOperandsDeviceType", prop.vectorOperandsDeviceType); if (prop.worker) attrs.append("worker", prop.worker); if (prop.workerNumOperandsDeviceType) attrs.append("workerNumOperandsDeviceType", prop.workerNumOperandsDeviceType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult LoopOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAuto_AttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "auto_", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCollapseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps15(attr, "collapse", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCollapseDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "collapseDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCombinedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps17(attr, "combined", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getGangAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "gang", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getGangOperandsArgTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps16(attr, "gangOperandsArgType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getGangOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "gangOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getGangOperandsSegmentsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(attr, "gangOperandsSegments", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getInclusiveUpperboundAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps14(attr, "inclusiveUpperbound", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getIndependentAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "independent", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSeqAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "seq", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getTileOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "tileOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getTileOperandsSegmentsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(attr, "tileOperandsSegments", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getUnstructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "unstructured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVectorAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "vector", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVectorOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "vectorOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWorkerAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "worker", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWorkerNumOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "workerNumOperandsDeviceType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult LoopOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.auto_))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.collapse))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.collapseDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.combined))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.gang))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.gangOperandsArgType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.gangOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.gangOperandsSegments))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.inclusiveUpperbound))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.independent))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.seq))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.tileOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.tileOperandsSegments))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.unstructured))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.vector))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.vectorOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.worker))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.workerNumOperandsDeviceType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void LoopOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.auto_); writer.writeOptionalAttribute(prop.collapse); writer.writeOptionalAttribute(prop.collapseDeviceType); writer.writeOptionalAttribute(prop.combined); writer.writeOptionalAttribute(prop.gang); writer.writeOptionalAttribute(prop.gangOperandsArgType); writer.writeOptionalAttribute(prop.gangOperandsDeviceType); writer.writeOptionalAttribute(prop.gangOperandsSegments); writer.writeOptionalAttribute(prop.inclusiveUpperbound); writer.writeOptionalAttribute(prop.independent); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.seq); writer.writeOptionalAttribute(prop.tileOperandsDeviceType); writer.writeOptionalAttribute(prop.tileOperandsSegments); writer.writeOptionalAttribute(prop.unstructured); writer.writeOptionalAttribute(prop.vector); writer.writeOptionalAttribute(prop.vectorOperandsDeviceType); writer.writeOptionalAttribute(prop.worker); writer.writeOptionalAttribute(prop.workerNumOperandsDeviceType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::std::optional<::llvm::ArrayRef> LoopOp::getInclusiveUpperbound() { auto attr = getInclusiveUpperboundAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOp::getCollapse() { auto attr = getCollapseAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOp::getCollapseDeviceType() { auto attr = getCollapseDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOp::getGangOperandsArgType() { auto attr = getGangOperandsArgTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> LoopOp::getGangOperandsSegments() { auto attr = getGangOperandsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOp::getGangOperandsDeviceType() { auto attr = getGangOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOp::getWorkerNumOperandsDeviceType() { auto attr = getWorkerNumOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOp::getVectorOperandsDeviceType() { auto attr = getVectorOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOp::getSeq() { auto attr = getSeqAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOp::getIndependent() { auto attr = getIndependentAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOp::getAuto_() { auto attr = getAuto_Attr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOp::getGang() { auto attr = getGangAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOp::getWorker() { auto attr = getWorkerAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOp::getVector() { auto attr = getVectorAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> LoopOp::getTileOperandsSegments() { auto attr = getTileOperandsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > LoopOp::getTileOperandsDeviceType() { auto attr = getTileOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::mlir::acc::CombinedConstructsType> LoopOp::getCombined() { auto attr = getCombinedAttr(); return attr ? ::std::optional<::mlir::acc::CombinedConstructsType>(attr.getValue()) : (::std::nullopt); } bool LoopOp::getUnstructured() { auto attr = getUnstructuredAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void LoopOp::setInclusiveUpperbound(::std::optional<::llvm::ArrayRef> attrValue) { auto &odsProp = getProperties().inclusiveUpperbound; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getDenseBoolArrayAttr(*attrValue); else odsProp = nullptr; } void LoopOp::setGangOperandsSegments(::std::optional<::llvm::ArrayRef> attrValue) { auto &odsProp = getProperties().gangOperandsSegments; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(*attrValue); else odsProp = nullptr; } void LoopOp::setTileOperandsSegments(::std::optional<::llvm::ArrayRef> attrValue) { auto &odsProp = getProperties().tileOperandsSegments; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(*attrValue); else odsProp = nullptr; } void LoopOp::setCombined(::std::optional<::mlir::acc::CombinedConstructsType> attrValue) { auto &odsProp = getProperties().combined; if (attrValue) odsProp = ::mlir::acc::CombinedConstructsTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void LoopOp::setUnstructured(bool attrValue) { auto &odsProp = getProperties().unstructured; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void LoopOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange lowerbounds, ::mlir::ValueRange upperbounds, ::mlir::ValueRange steps, LoopParMode parMode) { auto deviceNoneAttr = mlir::acc::DeviceTypeAttr::get( odsBuilder.getContext(), mlir::acc::DeviceType::None); auto arrOfDeviceNone = mlir::ArrayAttr::get( odsBuilder.getContext(), deviceNoneAttr); build(odsBuilder, odsState, /*results=*/{}, /*lowerbound=*/lowerbounds, /*upperbound=*/upperbounds, /*step=*/steps, /*inclusiveUpperbound=*/nullptr, /*collapse=*/nullptr, /*collapseDeviceType=*/nullptr, /*gangOperands=*/{}, /*gangOperandsArgType=*/nullptr, /*gangOperandsSegments=*/nullptr, /*gangOperandsDeviceType=*/nullptr, /*workerNumOperands=*/{}, /*workerNumOperandsDeviceType=*/nullptr, /*vectorOperands=*/{}, /*vectorOperandsDeviceType=*/nullptr, /*seq=*/parMode == LoopParMode::loop_seq ? arrOfDeviceNone : nullptr, /*independent=*/parMode == LoopParMode::loop_independent ? arrOfDeviceNone : nullptr, /*auto_=*/parMode == LoopParMode::loop_auto ? arrOfDeviceNone : nullptr, /*gang=*/nullptr, /*worker=*/nullptr, /*vector=*/nullptr, /*tileOperands=*/{}, /*tileOperandsSegments=*/nullptr, /*tileOperandsDeviceType=*/nullptr, /*cacheOperands=*/{}, /*privateOperands=*/{}, /*firstprivateOperands=*/{}, /*reductionOperands=*/{}, /*combined=*/nullptr); } LoopOp LoopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange lowerbounds, ::mlir::ValueRange upperbounds, ::mlir::ValueRange steps, LoopParMode parMode) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(lowerbounds), std::forward(upperbounds), std::forward(steps), std::forward(parMode)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoopOp LoopOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange lowerbounds, ::mlir::ValueRange upperbounds, ::mlir::ValueRange steps, LoopParMode parMode) { return create(builder, builder.getLoc(), std::forward(lowerbounds), std::forward(upperbounds), std::forward(steps), std::forward(parMode)); } void LoopOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange lowerbound, ::mlir::ValueRange upperbound, ::mlir::ValueRange step, /*optional*/::mlir::DenseBoolArrayAttr inclusiveUpperbound, /*optional*/::mlir::ArrayAttr collapse, /*optional*/::mlir::ArrayAttr collapseDeviceType, ::mlir::ValueRange gangOperands, /*optional*/::mlir::ArrayAttr gangOperandsArgType, /*optional*/::mlir::DenseI32ArrayAttr gangOperandsSegments, /*optional*/::mlir::ArrayAttr gangOperandsDeviceType, ::mlir::ValueRange workerNumOperands, /*optional*/::mlir::ArrayAttr workerNumOperandsDeviceType, ::mlir::ValueRange vectorOperands, /*optional*/::mlir::ArrayAttr vectorOperandsDeviceType, /*optional*/::mlir::ArrayAttr seq, /*optional*/::mlir::ArrayAttr independent, /*optional*/::mlir::ArrayAttr auto_, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, ::mlir::ValueRange tileOperands, /*optional*/::mlir::DenseI32ArrayAttr tileOperandsSegments, /*optional*/::mlir::ArrayAttr tileOperandsDeviceType, ::mlir::ValueRange cacheOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange reductionOperands, /*optional*/::mlir::acc::CombinedConstructsTypeAttr combined, /*optional*/::mlir::UnitAttr unstructured) { odsState.addOperands(lowerbound); odsState.addOperands(upperbound); odsState.addOperands(step); odsState.addOperands(gangOperands); odsState.addOperands(workerNumOperands); odsState.addOperands(vectorOperands); odsState.addOperands(tileOperands); odsState.addOperands(cacheOperands); odsState.addOperands(privateOperands); odsState.addOperands(firstprivateOperands); odsState.addOperands(reductionOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(lowerbound.size()), static_cast(upperbound.size()), static_cast(step.size()), static_cast(gangOperands.size()), static_cast(workerNumOperands.size()), static_cast(vectorOperands.size()), static_cast(tileOperands.size()), static_cast(cacheOperands.size()), static_cast(privateOperands.size()), static_cast(firstprivateOperands.size()), static_cast(reductionOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (inclusiveUpperbound) { odsState.getOrAddProperties().inclusiveUpperbound = inclusiveUpperbound; } if (collapse) { odsState.getOrAddProperties().collapse = collapse; } if (collapseDeviceType) { odsState.getOrAddProperties().collapseDeviceType = collapseDeviceType; } if (gangOperandsArgType) { odsState.getOrAddProperties().gangOperandsArgType = gangOperandsArgType; } if (gangOperandsSegments) { odsState.getOrAddProperties().gangOperandsSegments = gangOperandsSegments; } if (gangOperandsDeviceType) { odsState.getOrAddProperties().gangOperandsDeviceType = gangOperandsDeviceType; } if (workerNumOperandsDeviceType) { odsState.getOrAddProperties().workerNumOperandsDeviceType = workerNumOperandsDeviceType; } if (vectorOperandsDeviceType) { odsState.getOrAddProperties().vectorOperandsDeviceType = vectorOperandsDeviceType; } if (seq) { odsState.getOrAddProperties().seq = seq; } if (independent) { odsState.getOrAddProperties().independent = independent; } if (auto_) { odsState.getOrAddProperties().auto_ = auto_; } if (gang) { odsState.getOrAddProperties().gang = gang; } if (worker) { odsState.getOrAddProperties().worker = worker; } if (vector) { odsState.getOrAddProperties().vector = vector; } if (tileOperandsSegments) { odsState.getOrAddProperties().tileOperandsSegments = tileOperandsSegments; } if (tileOperandsDeviceType) { odsState.getOrAddProperties().tileOperandsDeviceType = tileOperandsDeviceType; } if (combined) { odsState.getOrAddProperties().combined = combined; } if (unstructured) { odsState.getOrAddProperties().unstructured = unstructured; } (void)odsState.addRegion(); odsState.addTypes(results); } LoopOp LoopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange results, ::mlir::ValueRange lowerbound, ::mlir::ValueRange upperbound, ::mlir::ValueRange step, /*optional*/::mlir::DenseBoolArrayAttr inclusiveUpperbound, /*optional*/::mlir::ArrayAttr collapse, /*optional*/::mlir::ArrayAttr collapseDeviceType, ::mlir::ValueRange gangOperands, /*optional*/::mlir::ArrayAttr gangOperandsArgType, /*optional*/::mlir::DenseI32ArrayAttr gangOperandsSegments, /*optional*/::mlir::ArrayAttr gangOperandsDeviceType, ::mlir::ValueRange workerNumOperands, /*optional*/::mlir::ArrayAttr workerNumOperandsDeviceType, ::mlir::ValueRange vectorOperands, /*optional*/::mlir::ArrayAttr vectorOperandsDeviceType, /*optional*/::mlir::ArrayAttr seq, /*optional*/::mlir::ArrayAttr independent, /*optional*/::mlir::ArrayAttr auto_, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, ::mlir::ValueRange tileOperands, /*optional*/::mlir::DenseI32ArrayAttr tileOperandsSegments, /*optional*/::mlir::ArrayAttr tileOperandsDeviceType, ::mlir::ValueRange cacheOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange reductionOperands, /*optional*/::mlir::acc::CombinedConstructsTypeAttr combined, /*optional*/::mlir::UnitAttr unstructured) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(results), std::forward(lowerbound), std::forward(upperbound), std::forward(step), std::forward(inclusiveUpperbound), std::forward(collapse), std::forward(collapseDeviceType), std::forward(gangOperands), std::forward(gangOperandsArgType), std::forward(gangOperandsSegments), std::forward(gangOperandsDeviceType), std::forward(workerNumOperands), std::forward(workerNumOperandsDeviceType), std::forward(vectorOperands), std::forward(vectorOperandsDeviceType), std::forward(seq), std::forward(independent), std::forward(auto_), std::forward(gang), std::forward(worker), std::forward(vector), std::forward(tileOperands), std::forward(tileOperandsSegments), std::forward(tileOperandsDeviceType), std::forward(cacheOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(reductionOperands), std::forward(combined), std::forward(unstructured)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoopOp LoopOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange results, ::mlir::ValueRange lowerbound, ::mlir::ValueRange upperbound, ::mlir::ValueRange step, /*optional*/::mlir::DenseBoolArrayAttr inclusiveUpperbound, /*optional*/::mlir::ArrayAttr collapse, /*optional*/::mlir::ArrayAttr collapseDeviceType, ::mlir::ValueRange gangOperands, /*optional*/::mlir::ArrayAttr gangOperandsArgType, /*optional*/::mlir::DenseI32ArrayAttr gangOperandsSegments, /*optional*/::mlir::ArrayAttr gangOperandsDeviceType, ::mlir::ValueRange workerNumOperands, /*optional*/::mlir::ArrayAttr workerNumOperandsDeviceType, ::mlir::ValueRange vectorOperands, /*optional*/::mlir::ArrayAttr vectorOperandsDeviceType, /*optional*/::mlir::ArrayAttr seq, /*optional*/::mlir::ArrayAttr independent, /*optional*/::mlir::ArrayAttr auto_, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, ::mlir::ValueRange tileOperands, /*optional*/::mlir::DenseI32ArrayAttr tileOperandsSegments, /*optional*/::mlir::ArrayAttr tileOperandsDeviceType, ::mlir::ValueRange cacheOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange reductionOperands, /*optional*/::mlir::acc::CombinedConstructsTypeAttr combined, /*optional*/::mlir::UnitAttr unstructured) { return create(builder, builder.getLoc(), std::forward(results), std::forward(lowerbound), std::forward(upperbound), std::forward(step), std::forward(inclusiveUpperbound), std::forward(collapse), std::forward(collapseDeviceType), std::forward(gangOperands), std::forward(gangOperandsArgType), std::forward(gangOperandsSegments), std::forward(gangOperandsDeviceType), std::forward(workerNumOperands), std::forward(workerNumOperandsDeviceType), std::forward(vectorOperands), std::forward(vectorOperandsDeviceType), std::forward(seq), std::forward(independent), std::forward(auto_), std::forward(gang), std::forward(worker), std::forward(vector), std::forward(tileOperands), std::forward(tileOperandsSegments), std::forward(tileOperandsDeviceType), std::forward(cacheOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(reductionOperands), std::forward(combined), std::forward(unstructured)); } void LoopOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange lowerbound, ::mlir::ValueRange upperbound, ::mlir::ValueRange step, /*optional*/::mlir::DenseBoolArrayAttr inclusiveUpperbound, /*optional*/::mlir::ArrayAttr collapse, /*optional*/::mlir::ArrayAttr collapseDeviceType, ::mlir::ValueRange gangOperands, /*optional*/::mlir::ArrayAttr gangOperandsArgType, /*optional*/::mlir::DenseI32ArrayAttr gangOperandsSegments, /*optional*/::mlir::ArrayAttr gangOperandsDeviceType, ::mlir::ValueRange workerNumOperands, /*optional*/::mlir::ArrayAttr workerNumOperandsDeviceType, ::mlir::ValueRange vectorOperands, /*optional*/::mlir::ArrayAttr vectorOperandsDeviceType, /*optional*/::mlir::ArrayAttr seq, /*optional*/::mlir::ArrayAttr independent, /*optional*/::mlir::ArrayAttr auto_, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, ::mlir::ValueRange tileOperands, /*optional*/::mlir::DenseI32ArrayAttr tileOperandsSegments, /*optional*/::mlir::ArrayAttr tileOperandsDeviceType, ::mlir::ValueRange cacheOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange reductionOperands, /*optional*/::mlir::acc::CombinedConstructsTypeAttr combined, /*optional*/bool unstructured) { odsState.addOperands(lowerbound); odsState.addOperands(upperbound); odsState.addOperands(step); odsState.addOperands(gangOperands); odsState.addOperands(workerNumOperands); odsState.addOperands(vectorOperands); odsState.addOperands(tileOperands); odsState.addOperands(cacheOperands); odsState.addOperands(privateOperands); odsState.addOperands(firstprivateOperands); odsState.addOperands(reductionOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(lowerbound.size()), static_cast(upperbound.size()), static_cast(step.size()), static_cast(gangOperands.size()), static_cast(workerNumOperands.size()), static_cast(vectorOperands.size()), static_cast(tileOperands.size()), static_cast(cacheOperands.size()), static_cast(privateOperands.size()), static_cast(firstprivateOperands.size()), static_cast(reductionOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (inclusiveUpperbound) { odsState.getOrAddProperties().inclusiveUpperbound = inclusiveUpperbound; } if (collapse) { odsState.getOrAddProperties().collapse = collapse; } if (collapseDeviceType) { odsState.getOrAddProperties().collapseDeviceType = collapseDeviceType; } if (gangOperandsArgType) { odsState.getOrAddProperties().gangOperandsArgType = gangOperandsArgType; } if (gangOperandsSegments) { odsState.getOrAddProperties().gangOperandsSegments = gangOperandsSegments; } if (gangOperandsDeviceType) { odsState.getOrAddProperties().gangOperandsDeviceType = gangOperandsDeviceType; } if (workerNumOperandsDeviceType) { odsState.getOrAddProperties().workerNumOperandsDeviceType = workerNumOperandsDeviceType; } if (vectorOperandsDeviceType) { odsState.getOrAddProperties().vectorOperandsDeviceType = vectorOperandsDeviceType; } if (seq) { odsState.getOrAddProperties().seq = seq; } if (independent) { odsState.getOrAddProperties().independent = independent; } if (auto_) { odsState.getOrAddProperties().auto_ = auto_; } if (gang) { odsState.getOrAddProperties().gang = gang; } if (worker) { odsState.getOrAddProperties().worker = worker; } if (vector) { odsState.getOrAddProperties().vector = vector; } if (tileOperandsSegments) { odsState.getOrAddProperties().tileOperandsSegments = tileOperandsSegments; } if (tileOperandsDeviceType) { odsState.getOrAddProperties().tileOperandsDeviceType = tileOperandsDeviceType; } if (combined) { odsState.getOrAddProperties().combined = combined; } if (unstructured) { odsState.getOrAddProperties().unstructured = ((unstructured) ? odsBuilder.getUnitAttr() : nullptr); } (void)odsState.addRegion(); odsState.addTypes(results); } LoopOp LoopOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange results, ::mlir::ValueRange lowerbound, ::mlir::ValueRange upperbound, ::mlir::ValueRange step, /*optional*/::mlir::DenseBoolArrayAttr inclusiveUpperbound, /*optional*/::mlir::ArrayAttr collapse, /*optional*/::mlir::ArrayAttr collapseDeviceType, ::mlir::ValueRange gangOperands, /*optional*/::mlir::ArrayAttr gangOperandsArgType, /*optional*/::mlir::DenseI32ArrayAttr gangOperandsSegments, /*optional*/::mlir::ArrayAttr gangOperandsDeviceType, ::mlir::ValueRange workerNumOperands, /*optional*/::mlir::ArrayAttr workerNumOperandsDeviceType, ::mlir::ValueRange vectorOperands, /*optional*/::mlir::ArrayAttr vectorOperandsDeviceType, /*optional*/::mlir::ArrayAttr seq, /*optional*/::mlir::ArrayAttr independent, /*optional*/::mlir::ArrayAttr auto_, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, ::mlir::ValueRange tileOperands, /*optional*/::mlir::DenseI32ArrayAttr tileOperandsSegments, /*optional*/::mlir::ArrayAttr tileOperandsDeviceType, ::mlir::ValueRange cacheOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange reductionOperands, /*optional*/::mlir::acc::CombinedConstructsTypeAttr combined, /*optional*/bool unstructured) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(results), std::forward(lowerbound), std::forward(upperbound), std::forward(step), std::forward(inclusiveUpperbound), std::forward(collapse), std::forward(collapseDeviceType), std::forward(gangOperands), std::forward(gangOperandsArgType), std::forward(gangOperandsSegments), std::forward(gangOperandsDeviceType), std::forward(workerNumOperands), std::forward(workerNumOperandsDeviceType), std::forward(vectorOperands), std::forward(vectorOperandsDeviceType), std::forward(seq), std::forward(independent), std::forward(auto_), std::forward(gang), std::forward(worker), std::forward(vector), std::forward(tileOperands), std::forward(tileOperandsSegments), std::forward(tileOperandsDeviceType), std::forward(cacheOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(reductionOperands), std::forward(combined), std::forward(unstructured)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } LoopOp LoopOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange results, ::mlir::ValueRange lowerbound, ::mlir::ValueRange upperbound, ::mlir::ValueRange step, /*optional*/::mlir::DenseBoolArrayAttr inclusiveUpperbound, /*optional*/::mlir::ArrayAttr collapse, /*optional*/::mlir::ArrayAttr collapseDeviceType, ::mlir::ValueRange gangOperands, /*optional*/::mlir::ArrayAttr gangOperandsArgType, /*optional*/::mlir::DenseI32ArrayAttr gangOperandsSegments, /*optional*/::mlir::ArrayAttr gangOperandsDeviceType, ::mlir::ValueRange workerNumOperands, /*optional*/::mlir::ArrayAttr workerNumOperandsDeviceType, ::mlir::ValueRange vectorOperands, /*optional*/::mlir::ArrayAttr vectorOperandsDeviceType, /*optional*/::mlir::ArrayAttr seq, /*optional*/::mlir::ArrayAttr independent, /*optional*/::mlir::ArrayAttr auto_, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, ::mlir::ValueRange tileOperands, /*optional*/::mlir::DenseI32ArrayAttr tileOperandsSegments, /*optional*/::mlir::ArrayAttr tileOperandsDeviceType, ::mlir::ValueRange cacheOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange reductionOperands, /*optional*/::mlir::acc::CombinedConstructsTypeAttr combined, /*optional*/bool unstructured) { return create(builder, builder.getLoc(), std::forward(results), std::forward(lowerbound), std::forward(upperbound), std::forward(step), std::forward(inclusiveUpperbound), std::forward(collapse), std::forward(collapseDeviceType), std::forward(gangOperands), std::forward(gangOperandsArgType), std::forward(gangOperandsSegments), std::forward(gangOperandsDeviceType), std::forward(workerNumOperands), std::forward(workerNumOperandsDeviceType), std::forward(vectorOperands), std::forward(vectorOperandsDeviceType), std::forward(seq), std::forward(independent), std::forward(auto_), std::forward(gang), std::forward(worker), std::forward(vector), std::forward(tileOperands), std::forward(tileOperandsSegments), std::forward(tileOperandsDeviceType), std::forward(cacheOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(reductionOperands), std::forward(combined), std::forward(unstructured)); } void LoopOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); 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."); } } LoopOp LoopOp::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__; } LoopOp LoopOp::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 LoopOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); odsState.addTypes(resultTypes); } LoopOp LoopOp::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__; } LoopOp LoopOp::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 LoopOp::verifyInvariantsImpl() { auto tblgen_auto_ = getProperties().auto_; (void)tblgen_auto_; auto tblgen_collapse = getProperties().collapse; (void)tblgen_collapse; auto tblgen_collapseDeviceType = getProperties().collapseDeviceType; (void)tblgen_collapseDeviceType; auto tblgen_combined = getProperties().combined; (void)tblgen_combined; auto tblgen_gang = getProperties().gang; (void)tblgen_gang; auto tblgen_gangOperandsArgType = getProperties().gangOperandsArgType; (void)tblgen_gangOperandsArgType; auto tblgen_gangOperandsDeviceType = getProperties().gangOperandsDeviceType; (void)tblgen_gangOperandsDeviceType; auto tblgen_gangOperandsSegments = getProperties().gangOperandsSegments; (void)tblgen_gangOperandsSegments; auto tblgen_inclusiveUpperbound = getProperties().inclusiveUpperbound; (void)tblgen_inclusiveUpperbound; auto tblgen_independent = getProperties().independent; (void)tblgen_independent; auto tblgen_seq = getProperties().seq; (void)tblgen_seq; auto tblgen_tileOperandsDeviceType = getProperties().tileOperandsDeviceType; (void)tblgen_tileOperandsDeviceType; auto tblgen_tileOperandsSegments = getProperties().tileOperandsSegments; (void)tblgen_tileOperandsSegments; auto tblgen_unstructured = getProperties().unstructured; (void)tblgen_unstructured; auto tblgen_vector = getProperties().vector; (void)tblgen_vector; auto tblgen_vectorOperandsDeviceType = getProperties().vectorOperandsDeviceType; (void)tblgen_vectorOperandsDeviceType; auto tblgen_worker = getProperties().worker; (void)tblgen_worker; auto tblgen_workerNumOperandsDeviceType = getProperties().workerNumOperandsDeviceType; (void)tblgen_workerNumOperandsDeviceType; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps14(*this, tblgen_inclusiveUpperbound, "inclusiveUpperbound"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps15(*this, tblgen_collapse, "collapse"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_collapseDeviceType, "collapseDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps16(*this, tblgen_gangOperandsArgType, "gangOperandsArgType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(*this, tblgen_gangOperandsSegments, "gangOperandsSegments"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_gangOperandsDeviceType, "gangOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_workerNumOperandsDeviceType, "workerNumOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_vectorOperandsDeviceType, "vectorOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_seq, "seq"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_independent, "independent"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_auto_, "auto_"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_gang, "gang"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_worker, "worker"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_vector, "vector"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(*this, tblgen_tileOperandsSegments, "tileOperandsSegments"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_tileOperandsDeviceType, "tileOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps17(*this, tblgen_combined, "combined"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_unstructured, "unstructured"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup5 = getODSOperands(5); for (auto v : valueGroup5) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup6 = getODSOperands(6); for (auto v : valueGroup6) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup7 = getODSOperands(7); for (auto v : valueGroup7) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup8 = getODSOperands(8); for (auto v : valueGroup8) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup9 = getODSOperands(9); for (auto v : valueGroup9) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup10 = getODSOperands(10); for (auto v : valueGroup10) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps9(*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_OpenACCOps9(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult LoopOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult LoopOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::acc::CombinedConstructsTypeAttr combinedAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> gangOperandsOperands; ::llvm::SMLoc gangOperandsOperandsLoc; (void)gangOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> gangOperandsTypes; ::mlir::ArrayAttr gangOperandsArgTypeAttr; ::mlir::ArrayAttr gangOperandsDeviceTypeAttr; ::mlir::DenseI32ArrayAttr gangOperandsSegmentsAttr; ::mlir::ArrayAttr gangAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> workerNumOperandsOperands; ::llvm::SMLoc workerNumOperandsOperandsLoc; (void)workerNumOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> workerNumOperandsTypes; ::mlir::ArrayAttr workerNumOperandsDeviceTypeAttr; ::mlir::ArrayAttr workerAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> vectorOperandsOperands; ::llvm::SMLoc vectorOperandsOperandsLoc; (void)vectorOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> vectorOperandsTypes; ::mlir::ArrayAttr vectorOperandsDeviceTypeAttr; ::mlir::ArrayAttr vectorAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> privateOperandsOperands; ::llvm::SMLoc privateOperandsOperandsLoc; (void)privateOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> privateOperandsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> firstprivateOperandsOperands; ::llvm::SMLoc firstprivateOperandsOperandsLoc; (void)firstprivateOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> firstprivateOperandsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> tileOperandsOperands; ::llvm::SMLoc tileOperandsOperandsLoc; (void)tileOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> tileOperandsTypes; ::mlir::ArrayAttr tileOperandsDeviceTypeAttr; ::mlir::DenseI32ArrayAttr tileOperandsSegmentsAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> reductionOperandsOperands; ::llvm::SMLoc reductionOperandsOperandsLoc; (void)reductionOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> reductionOperandsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> cacheOperandsOperands; ::llvm::SMLoc cacheOperandsOperandsLoc; (void)cacheOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> cacheOperandsTypes; std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> lowerboundOperands; ::llvm::SMLoc lowerboundOperandsLoc; (void)lowerboundOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> lowerboundTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> upperboundOperands; ::llvm::SMLoc upperboundOperandsLoc; (void)upperboundOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> upperboundTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> stepOperands; ::llvm::SMLoc stepOperandsLoc; (void)stepOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> stepTypes; ::llvm::SmallVector<::mlir::Type, 1> resultsTypes; if (::mlir::succeeded(parser.parseOptionalKeyword("combined"))) { if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseCombinedConstructsLoop(parser, combinedAttr); if (odsResult) return ::mlir::failure(); if (combinedAttr) result.getOrAddProperties().combined = combinedAttr; } if (parser.parseRParen()) return ::mlir::failure(); } bool gangClause = false; bool workerClause = false; bool vectorClause = false; bool privateClause = false; bool firstprivateClause = false; bool tileClause = false; bool reductionClause = false; bool cacheClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("gang"))) { if (gangClause) { return parser.emitError(parser.getNameLoc()) << "`gang` clause can appear at most once in the expansion of the " "oilist directive"; } gangClause = true; { gangOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseGangClause(parser, gangOperandsOperands, gangOperandsTypes, gangOperandsArgTypeAttr, gangOperandsDeviceTypeAttr, gangOperandsSegmentsAttr, gangAttr); if (odsResult) return ::mlir::failure(); if (gangOperandsArgTypeAttr) result.getOrAddProperties().gangOperandsArgType = gangOperandsArgTypeAttr; if (gangOperandsDeviceTypeAttr) result.getOrAddProperties().gangOperandsDeviceType = gangOperandsDeviceTypeAttr; if (gangOperandsSegmentsAttr) result.getOrAddProperties().gangOperandsSegments = gangOperandsSegmentsAttr; if (gangAttr) result.getOrAddProperties().gang = gangAttr; } } else if (succeeded(parser.parseOptionalKeyword("worker"))) { if (workerClause) { return parser.emitError(parser.getNameLoc()) << "`worker` clause can appear at most once in the expansion of the " "oilist directive"; } workerClause = true; { workerNumOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, workerNumOperandsOperands, workerNumOperandsTypes, workerNumOperandsDeviceTypeAttr, workerAttr); if (odsResult) return ::mlir::failure(); if (workerNumOperandsDeviceTypeAttr) result.getOrAddProperties().workerNumOperandsDeviceType = workerNumOperandsDeviceTypeAttr; if (workerAttr) result.getOrAddProperties().worker = workerAttr; } } else if (succeeded(parser.parseOptionalKeyword("vector"))) { if (vectorClause) { return parser.emitError(parser.getNameLoc()) << "`vector` clause can appear at most once in the expansion of the " "oilist directive"; } vectorClause = true; { vectorOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, vectorOperandsOperands, vectorOperandsTypes, vectorOperandsDeviceTypeAttr, vectorAttr); if (odsResult) return ::mlir::failure(); if (vectorOperandsDeviceTypeAttr) result.getOrAddProperties().vectorOperandsDeviceType = vectorOperandsDeviceTypeAttr; if (vectorAttr) result.getOrAddProperties().vector = vectorAttr; } } else if (succeeded(parser.parseOptionalKeyword("private"))) { if (privateClause) { return parser.emitError(parser.getNameLoc()) << "`private` clause can appear at most once in the expansion of the " "oilist directive"; } privateClause = true; if (parser.parseLParen()) return ::mlir::failure(); privateOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(privateOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(privateOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("firstprivate"))) { if (firstprivateClause) { return parser.emitError(parser.getNameLoc()) << "`firstprivate` clause can appear at most once in the expansion of the " "oilist directive"; } firstprivateClause = true; if (parser.parseLParen()) return ::mlir::failure(); firstprivateOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(firstprivateOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(firstprivateOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("tile"))) { if (tileClause) { return parser.emitError(parser.getNameLoc()) << "`tile` clause can appear at most once in the expansion of the " "oilist directive"; } tileClause = true; if (parser.parseLParen()) return ::mlir::failure(); { tileOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithSegment(parser, tileOperandsOperands, tileOperandsTypes, tileOperandsDeviceTypeAttr, tileOperandsSegmentsAttr); if (odsResult) return ::mlir::failure(); if (tileOperandsDeviceTypeAttr) result.getOrAddProperties().tileOperandsDeviceType = tileOperandsDeviceTypeAttr; if (tileOperandsSegmentsAttr) result.getOrAddProperties().tileOperandsSegments = tileOperandsSegmentsAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("reduction"))) { if (reductionClause) { return parser.emitError(parser.getNameLoc()) << "`reduction` clause can appear at most once in the expansion of the " "oilist directive"; } reductionClause = true; if (parser.parseLParen()) return ::mlir::failure(); reductionOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(reductionOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(reductionOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("cache"))) { if (cacheClause) { return parser.emitError(parser.getNameLoc()) << "`cache` clause can appear at most once in the expansion of the " "oilist directive"; } cacheClause = true; if (parser.parseLParen()) return ::mlir::failure(); cacheOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(cacheOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(cacheOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } { lowerboundOperandsLoc = parser.getCurrentLocation(); upperboundOperandsLoc = parser.getCurrentLocation(); stepOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseLoopControl(parser, *regionRegion, lowerboundOperands, lowerboundTypes, upperboundOperands, upperboundTypes, stepOperands, stepTypes); if (odsResult) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalLParen())) { if (parser.parseTypeList(resultsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } { 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(); } result.addRegion(std::move(regionRegion)); ::llvm::copy(::llvm::ArrayRef({static_cast(lowerboundOperands.size()), static_cast(upperboundOperands.size()), static_cast(stepOperands.size()), static_cast(gangOperandsOperands.size()), static_cast(workerNumOperandsOperands.size()), static_cast(vectorOperandsOperands.size()), static_cast(tileOperandsOperands.size()), static_cast(cacheOperandsOperands.size()), static_cast(privateOperandsOperands.size()), static_cast(firstprivateOperandsOperands.size()), static_cast(reductionOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); result.addTypes(resultsTypes); if (parser.resolveOperands(lowerboundOperands, lowerboundTypes, lowerboundOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(upperboundOperands, upperboundTypes, upperboundOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(stepOperands, stepTypes, stepOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(gangOperandsOperands, gangOperandsTypes, gangOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(workerNumOperandsOperands, workerNumOperandsTypes, workerNumOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(vectorOperandsOperands, vectorOperandsTypes, vectorOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(tileOperandsOperands, tileOperandsTypes, tileOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(cacheOperandsOperands, cacheOperandsTypes, cacheOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(privateOperandsOperands, privateOperandsTypes, privateOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(firstprivateOperandsOperands, firstprivateOperandsTypes, firstprivateOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(reductionOperandsOperands, reductionOperandsTypes, reductionOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void LoopOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (((getCombinedAttr()))) { _odsPrinter << ' ' << "combined"; _odsPrinter << "("; printCombinedConstructsLoop(_odsPrinter, *this, getCombinedAttr()); _odsPrinter << ")"; } if (false || getGangOperands().size() || (getGangOperandsArgTypeAttr()) || (getGangOperandsDeviceTypeAttr()) || (getGangOperandsSegmentsAttr()) || (getGangAttr())) { _odsPrinter << ' ' << "gang"; printGangClause(_odsPrinter, *this, getGangOperands(), getGangOperands().getTypes(), getGangOperandsArgTypeAttr(), getGangOperandsDeviceTypeAttr(), getGangOperandsSegmentsAttr(), getGangAttr()); } if (false || getWorkerNumOperands().size() || (getWorkerNumOperandsDeviceTypeAttr()) || (getWorkerAttr())) { _odsPrinter << ' ' << "worker"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getWorkerNumOperands(), getWorkerNumOperands().getTypes(), getWorkerNumOperandsDeviceTypeAttr(), getWorkerAttr()); } if (false || getVectorOperands().size() || (getVectorOperandsDeviceTypeAttr()) || (getVectorAttr())) { _odsPrinter << ' ' << "vector"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getVectorOperands(), getVectorOperands().getTypes(), getVectorOperandsDeviceTypeAttr(), getVectorAttr()); } if (false || getPrivateOperands().size()) { _odsPrinter << ' ' << "private"; _odsPrinter << "("; _odsPrinter << getPrivateOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getPrivateOperands().getTypes(); _odsPrinter << ")"; } if (false || getFirstprivateOperands().size()) { _odsPrinter << ' ' << "firstprivate"; _odsPrinter << "("; _odsPrinter << getFirstprivateOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getFirstprivateOperands().getTypes(); _odsPrinter << ")"; } if (false || getTileOperands().size() || (getTileOperandsDeviceTypeAttr()) || (getTileOperandsSegmentsAttr())) { _odsPrinter << ' ' << "tile"; _odsPrinter << "("; printDeviceTypeOperandsWithSegment(_odsPrinter, *this, getTileOperands(), getTileOperands().getTypes(), getTileOperandsDeviceTypeAttr(), getTileOperandsSegmentsAttr()); _odsPrinter << ")"; } if (false || getReductionOperands().size()) { _odsPrinter << ' ' << "reduction"; _odsPrinter << "("; _odsPrinter << getReductionOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getReductionOperands().getTypes(); _odsPrinter << ")"; } if (false || getCacheOperands().size()) { _odsPrinter << ' ' << "cache"; _odsPrinter << "("; _odsPrinter << getCacheOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getCacheOperands().getTypes(); _odsPrinter << ")"; } _odsPrinter << ' '; printLoopControl(_odsPrinter, *this, getRegion(), getLowerbound(), getLowerbound().getTypes(), getUpperbound(), getUpperbound().getTypes(), getStep(), getStep().getTypes()); if (!getResults().empty()) { _odsPrinter << "("; _odsPrinter << getResults().getTypes(); _odsPrinter << ")"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("combined"); elidedAttrs.push_back("gangOperandsArgType"); elidedAttrs.push_back("gangOperandsDeviceType"); elidedAttrs.push_back("gangOperandsSegments"); elidedAttrs.push_back("gang"); elidedAttrs.push_back("workerNumOperandsDeviceType"); elidedAttrs.push_back("worker"); elidedAttrs.push_back("vectorOperandsDeviceType"); elidedAttrs.push_back("vector"); elidedAttrs.push_back("tileOperandsDeviceType"); elidedAttrs.push_back("tileOperandsSegments"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getUnstructuredAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("unstructured"); } _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } void LoopOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::acc::ConstructResource::get()); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::LoopOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::LoopOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::NoCreateOp definitions //===----------------------------------------------------------------------===// namespace detail { NoCreateOpGenericAdaptorBase::NoCreateOpGenericAdaptorBase(NoCreateOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair NoCreateOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type NoCreateOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > NoCreateOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > NoCreateOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr NoCreateOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause NoCreateOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr NoCreateOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool NoCreateOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr NoCreateOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool NoCreateOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr NoCreateOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier NoCreateOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > NoCreateOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > NoCreateOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail NoCreateOpAdaptor::NoCreateOpAdaptor(NoCreateOp op) : NoCreateOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult NoCreateOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.nocreate' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.nocreate' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.nocreate' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.nocreate' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.nocreate' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.nocreate' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.nocreate' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.nocreate' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.nocreate' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.nocreate' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair NoCreateOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange NoCreateOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange NoCreateOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange NoCreateOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult NoCreateOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute NoCreateOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code NoCreateOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional NoCreateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void NoCreateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void NoCreateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult NoCreateOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult NoCreateOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void NoCreateOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type NoCreateOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > NoCreateOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > NoCreateOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause NoCreateOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool NoCreateOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool NoCreateOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier NoCreateOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > NoCreateOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > NoCreateOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void NoCreateOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void NoCreateOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void NoCreateOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void NoCreateOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void NoCreateOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void NoCreateOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void NoCreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } NoCreateOp NoCreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NoCreateOp NoCreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void NoCreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } NoCreateOp NoCreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NoCreateOp NoCreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void NoCreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } NoCreateOp NoCreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NoCreateOp NoCreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void NoCreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } NoCreateOp NoCreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NoCreateOp NoCreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void NoCreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } NoCreateOp NoCreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NoCreateOp NoCreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void NoCreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } NoCreateOp NoCreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NoCreateOp NoCreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void NoCreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } NoCreateOp NoCreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NoCreateOp NoCreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void NoCreateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } NoCreateOp NoCreateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } NoCreateOp NoCreateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void NoCreateOp::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."); } } NoCreateOp NoCreateOp::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__; } NoCreateOp NoCreateOp::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 NoCreateOp::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); } NoCreateOp NoCreateOp::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__; } NoCreateOp NoCreateOp::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 NoCreateOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_no_create); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult NoCreateOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult NoCreateOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult NoCreateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void NoCreateOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_no_create))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::NoCreateOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::NoCreateOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::ParWidthOp definitions //===----------------------------------------------------------------------===// namespace detail { ParWidthOpGenericAdaptorBase::ParWidthOpGenericAdaptorBase(ParWidthOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ParWidthOpGenericAdaptorBase::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}; } ::mlir::acc::GPUParallelDimAttr ParWidthOpGenericAdaptorBase::getParDim() { auto attr = getParDimAttr(); return ::llvm::cast<::mlir::acc::GPUParallelDimAttr>(attr); } } // namespace detail ParWidthOpAdaptor::ParWidthOpAdaptor(ParWidthOp op) : ParWidthOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ParWidthOpAdaptor::verify(::mlir::Location loc) { auto tblgen_par_dim = getProperties().par_dim; (void)tblgen_par_dim; if (!tblgen_par_dim) return emitError(loc, "'acc.par_width' op requires attribute 'par_dim'"); if (tblgen_par_dim && !((::llvm::isa<::mlir::acc::GPUParallelDimAttr>(tblgen_par_dim)))) return emitError(loc, "'acc.par_width' op attribute 'par_dim' failed to satisfy constraint: GPU parallel dimension for use in OpenACC parallelism assignment."); return ::mlir::success(); } std::pair ParWidthOp::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 ParWidthOp::getLaunchArgMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult ParWidthOp::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.par_dim; auto attr = dict.get("par_dim"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `par_dim` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ParWidthOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.par_dim; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("par_dim", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ParWidthOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.par_dim.getAsOpaquePointer())); } std::optional ParWidthOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "par_dim") return prop.par_dim; return std::nullopt; } void ParWidthOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "par_dim") { prop.par_dim = ::llvm::dyn_cast_or_null>(value); return; } } void ParWidthOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.par_dim) attrs.append("par_dim", prop.par_dim); } ::llvm::LogicalResult ParWidthOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getParDimAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps18(attr, "par_dim", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ParWidthOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.par_dim))) return ::mlir::failure(); return ::mlir::success(); } void ParWidthOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.par_dim); } ::mlir::acc::GPUParallelDimAttr ParWidthOp::getParDim() { auto attr = getParDimAttr(); return ::llvm::cast<::mlir::acc::GPUParallelDimAttr>(attr); } void ParWidthOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, /*optional*/::mlir::Value launchArg, ::mlir::acc::GPUParallelDimAttr par_dim) { if (launchArg) odsState.addOperands(launchArg); odsState.getOrAddProperties().par_dim = par_dim; odsState.addTypes(output); } ParWidthOp ParWidthOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, /*optional*/::mlir::Value launchArg, ::mlir::acc::GPUParallelDimAttr par_dim) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(output), std::forward(launchArg), std::forward(par_dim)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ParWidthOp ParWidthOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, /*optional*/::mlir::Value launchArg, ::mlir::acc::GPUParallelDimAttr par_dim) { return create(builder, builder.getLoc(), std::forward(output), std::forward(launchArg), std::forward(par_dim)); } void ParWidthOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value launchArg, ::mlir::acc::GPUParallelDimAttr par_dim) { if (launchArg) odsState.addOperands(launchArg); odsState.getOrAddProperties().par_dim = par_dim; ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ParWidthOp::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); } ParWidthOp ParWidthOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value launchArg, ::mlir::acc::GPUParallelDimAttr par_dim) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(launchArg), std::forward(par_dim)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ParWidthOp ParWidthOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value launchArg, ::mlir::acc::GPUParallelDimAttr par_dim) { return create(builder, builder.getLoc(), std::forward(launchArg), std::forward(par_dim)); } void ParWidthOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value launchArg, ::mlir::acc::GPUParallelDimAttr par_dim) { if (launchArg) odsState.addOperands(launchArg); odsState.getOrAddProperties().par_dim = par_dim; assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ParWidthOp ParWidthOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value launchArg, ::mlir::acc::GPUParallelDimAttr par_dim) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(launchArg), std::forward(par_dim)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ParWidthOp ParWidthOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value launchArg, ::mlir::acc::GPUParallelDimAttr par_dim) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(launchArg), std::forward(par_dim)); } void ParWidthOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ParWidthOp ParWidthOp::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__; } ParWidthOp ParWidthOp::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 ParWidthOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { 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(ParWidthOp::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)."); } } ParWidthOp ParWidthOp::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__; } ParWidthOp ParWidthOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ParWidthOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ParWidthOp ParWidthOp::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__; } ParWidthOp ParWidthOp::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 ParWidthOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ParWidthOp::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)."); } } ParWidthOp ParWidthOp::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__; } ParWidthOp ParWidthOp::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 ParWidthOp::verifyInvariantsImpl() { auto tblgen_par_dim = getProperties().par_dim; (void)tblgen_par_dim; if (!tblgen_par_dim) return emitOpError("requires attribute 'par_dim'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps18(*this, tblgen_par_dim, "par_dim"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); if (valueGroup0.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup0.size(); } for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps15(*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_OpenACCOps15(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ParWidthOp::verifyInvariants() { return verifyInvariantsImpl(); } ::llvm::LogicalResult ParWidthOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { inferredReturnTypes.resize(1); ::mlir::Builder odsBuilder(context); ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); inferredReturnTypes[0] = odsInferredType0; return ::mlir::success(); } ::mlir::ParseResult ParWidthOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> launchArgOperands; ::llvm::SMLoc launchArgOperandsLoc; (void)launchArgOperandsLoc; { launchArgOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); launchArgOperands.push_back(operand); } } if (!launchArgOperands.empty()) { } { 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(); } ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); result.addTypes(odsBuildableType0); if (!launchArgOperands.empty()) { if (parser.resolveOperands(launchArgOperands, odsBuildableType0, launchArgOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void ParWidthOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (getLaunchArg()) { _odsPrinter << ' '; if (::mlir::Value value = getLaunchArg()) _odsPrinter << value; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } void ParWidthOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::ParWidthOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::ParWidthOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::ParallelOp definitions //===----------------------------------------------------------------------===// namespace detail { ParallelOpGenericAdaptorBase::ParallelOpGenericAdaptorBase(ParallelOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ParallelOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::std::optional< ::mlir::ArrayAttr > ParallelOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ParallelOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> ParallelOpGenericAdaptorBase::getWaitOperandsSegments() { auto attr = getWaitOperandsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ParallelOpGenericAdaptorBase::getWaitOperandsDeviceType() { auto attr = getWaitOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ParallelOpGenericAdaptorBase::getHasWaitDevnum() { auto attr = getHasWaitDevnumAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ParallelOpGenericAdaptorBase::getWaitOnly() { auto attr = getWaitOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> ParallelOpGenericAdaptorBase::getNumGangsSegments() { auto attr = getNumGangsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ParallelOpGenericAdaptorBase::getNumGangsDeviceType() { auto attr = getNumGangsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ParallelOpGenericAdaptorBase::getNumWorkersDeviceType() { auto attr = getNumWorkersDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ParallelOpGenericAdaptorBase::getVectorLengthDeviceType() { auto attr = getVectorLengthDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::UnitAttr ParallelOpGenericAdaptorBase::getSelfAttrAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().selfAttr); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool ParallelOpGenericAdaptorBase::getSelfAttr() { auto attr = getSelfAttrAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::std::optional<::mlir::acc::ClauseDefaultValue> ParallelOpGenericAdaptorBase::getDefaultAttr() { auto attr = getDefaultAttrAttr(); return attr ? ::std::optional<::mlir::acc::ClauseDefaultValue>(attr.getValue()) : (::std::nullopt); } ::mlir::UnitAttr ParallelOpGenericAdaptorBase::getCombinedAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().combined); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool ParallelOpGenericAdaptorBase::getCombined() { auto attr = getCombinedAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail ParallelOpAdaptor::ParallelOpAdaptor(ParallelOp op) : ParallelOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ParallelOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_combined = getProperties().combined; (void)tblgen_combined; auto tblgen_defaultAttr = getProperties().defaultAttr; (void)tblgen_defaultAttr; auto tblgen_hasWaitDevnum = getProperties().hasWaitDevnum; (void)tblgen_hasWaitDevnum; auto tblgen_numGangsDeviceType = getProperties().numGangsDeviceType; (void)tblgen_numGangsDeviceType; auto tblgen_numGangsSegments = getProperties().numGangsSegments; (void)tblgen_numGangsSegments; auto tblgen_numWorkersDeviceType = getProperties().numWorkersDeviceType; (void)tblgen_numWorkersDeviceType; auto tblgen_selfAttr = getProperties().selfAttr; (void)tblgen_selfAttr; auto tblgen_vectorLengthDeviceType = getProperties().vectorLengthDeviceType; (void)tblgen_vectorLengthDeviceType; auto tblgen_waitOnly = getProperties().waitOnly; (void)tblgen_waitOnly; auto tblgen_waitOperandsDeviceType = getProperties().waitOperandsDeviceType; (void)tblgen_waitOperandsDeviceType; auto tblgen_waitOperandsSegments = getProperties().waitOperandsSegments; (void)tblgen_waitOperandsSegments; if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.parallel' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.parallel' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_waitOperandsSegments && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_waitOperandsSegments)))) return emitError(loc, "'acc.parallel' op attribute 'waitOperandsSegments' failed to satisfy constraint: i32 dense array attribute"); if (tblgen_waitOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_waitOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_waitOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.parallel' op attribute 'waitOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_hasWaitDevnum && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_hasWaitDevnum))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_hasWaitDevnum), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::BoolAttr>(attr))); })))) return emitError(loc, "'acc.parallel' op attribute 'hasWaitDevnum' failed to satisfy constraint: 1-bit boolean array attribute"); if (tblgen_waitOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_waitOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_waitOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.parallel' op attribute 'waitOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_numGangsSegments && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_numGangsSegments)))) return emitError(loc, "'acc.parallel' op attribute 'numGangsSegments' failed to satisfy constraint: i32 dense array attribute"); if (tblgen_numGangsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_numGangsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_numGangsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.parallel' op attribute 'numGangsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_numWorkersDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_numWorkersDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_numWorkersDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.parallel' op attribute 'numWorkersDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_vectorLengthDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_vectorLengthDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_vectorLengthDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.parallel' op attribute 'vectorLengthDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_selfAttr && !((::llvm::isa<::mlir::UnitAttr>(tblgen_selfAttr)))) return emitError(loc, "'acc.parallel' op attribute 'selfAttr' failed to satisfy constraint: unit attribute"); if (tblgen_defaultAttr && !((::llvm::isa<::mlir::acc::ClauseDefaultValueAttr>(tblgen_defaultAttr)))) return emitError(loc, "'acc.parallel' op attribute 'defaultAttr' failed to satisfy constraint: DefaultValue Clause"); if (tblgen_combined && !((::llvm::isa<::mlir::UnitAttr>(tblgen_combined)))) return emitError(loc, "'acc.parallel' op attribute 'combined' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } std::pair ParallelOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange ParallelOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ParallelOp::getWaitOperandsMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ParallelOp::getNumGangsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ParallelOp::getNumWorkersMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ParallelOp::getVectorLengthMutable() { auto range = getODSOperandIndexAndLength(4); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(4u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ParallelOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(5); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(5u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ParallelOp::getSelfCondMutable() { auto range = getODSOperandIndexAndLength(6); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(6u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ParallelOp::getReductionOperandsMutable() { auto range = getODSOperandIndexAndLength(7); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(7u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ParallelOp::getPrivateOperandsMutable() { auto range = getODSOperandIndexAndLength(8); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(8u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ParallelOp::getFirstprivateOperandsMutable() { auto range = getODSOperandIndexAndLength(9); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(9u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ParallelOp::getDataClauseOperandsMutable() { auto range = getODSOperandIndexAndLength(10); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(10u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult ParallelOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.combined; auto attr = dict.get("combined"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `combined` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.defaultAttr; auto attr = dict.get("defaultAttr"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `defaultAttr` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.hasWaitDevnum; auto attr = dict.get("hasWaitDevnum"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `hasWaitDevnum` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.numGangsDeviceType; auto attr = dict.get("numGangsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `numGangsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.numGangsSegments; auto attr = dict.get("numGangsSegments"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `numGangsSegments` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.numWorkersDeviceType; auto attr = dict.get("numWorkersDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `numWorkersDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.selfAttr; auto attr = dict.get("selfAttr"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `selfAttr` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.vectorLengthDeviceType; auto attr = dict.get("vectorLengthDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `vectorLengthDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOnly; auto attr = dict.get("waitOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOperandsDeviceType; auto attr = dict.get("waitOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOperandsSegments; auto attr = dict.get("waitOperandsSegments"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOperandsSegments` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute ParallelOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.combined; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("combined", propStorage)); } { const auto &propStorage = prop.defaultAttr; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("defaultAttr", propStorage)); } { const auto &propStorage = prop.hasWaitDevnum; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("hasWaitDevnum", propStorage)); } { const auto &propStorage = prop.numGangsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("numGangsDeviceType", propStorage)); } { const auto &propStorage = prop.numGangsSegments; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("numGangsSegments", propStorage)); } { const auto &propStorage = prop.numWorkersDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("numWorkersDeviceType", propStorage)); } { const auto &propStorage = prop.selfAttr; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("selfAttr", propStorage)); } { const auto &propStorage = prop.vectorLengthDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("vectorLengthDeviceType", propStorage)); } { const auto &propStorage = prop.waitOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOnly", propStorage)); } { const auto &propStorage = prop.waitOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.waitOperandsSegments; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOperandsSegments", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ParallelOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.combined.getAsOpaquePointer()), llvm::hash_value(prop.defaultAttr.getAsOpaquePointer()), llvm::hash_value(prop.hasWaitDevnum.getAsOpaquePointer()), llvm::hash_value(prop.numGangsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.numGangsSegments.getAsOpaquePointer()), llvm::hash_value(prop.numWorkersDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.selfAttr.getAsOpaquePointer()), llvm::hash_value(prop.vectorLengthDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.waitOnly.getAsOpaquePointer()), llvm::hash_value(prop.waitOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.waitOperandsSegments.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional ParallelOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "combined") return prop.combined; if (name == "defaultAttr") return prop.defaultAttr; if (name == "hasWaitDevnum") return prop.hasWaitDevnum; if (name == "numGangsDeviceType") return prop.numGangsDeviceType; if (name == "numGangsSegments") return prop.numGangsSegments; if (name == "numWorkersDeviceType") return prop.numWorkersDeviceType; if (name == "selfAttr") return prop.selfAttr; if (name == "vectorLengthDeviceType") return prop.vectorLengthDeviceType; if (name == "waitOnly") return prop.waitOnly; if (name == "waitOperandsDeviceType") return prop.waitOperandsDeviceType; if (name == "waitOperandsSegments") return prop.waitOperandsSegments; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void ParallelOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "combined") { prop.combined = ::llvm::dyn_cast_or_null>(value); return; } if (name == "defaultAttr") { prop.defaultAttr = ::llvm::dyn_cast_or_null>(value); return; } if (name == "hasWaitDevnum") { prop.hasWaitDevnum = ::llvm::dyn_cast_or_null>(value); return; } if (name == "numGangsDeviceType") { prop.numGangsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "numGangsSegments") { prop.numGangsSegments = ::llvm::dyn_cast_or_null>(value); return; } if (name == "numWorkersDeviceType") { prop.numWorkersDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "selfAttr") { prop.selfAttr = ::llvm::dyn_cast_or_null>(value); return; } if (name == "vectorLengthDeviceType") { prop.vectorLengthDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOnly") { prop.waitOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOperandsDeviceType") { prop.waitOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOperandsSegments") { prop.waitOperandsSegments = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void ParallelOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.combined) attrs.append("combined", prop.combined); if (prop.defaultAttr) attrs.append("defaultAttr", prop.defaultAttr); if (prop.hasWaitDevnum) attrs.append("hasWaitDevnum", prop.hasWaitDevnum); if (prop.numGangsDeviceType) attrs.append("numGangsDeviceType", prop.numGangsDeviceType); if (prop.numGangsSegments) attrs.append("numGangsSegments", prop.numGangsSegments); if (prop.numWorkersDeviceType) attrs.append("numWorkersDeviceType", prop.numWorkersDeviceType); if (prop.selfAttr) attrs.append("selfAttr", prop.selfAttr); if (prop.vectorLengthDeviceType) attrs.append("vectorLengthDeviceType", prop.vectorLengthDeviceType); if (prop.waitOnly) attrs.append("waitOnly", prop.waitOnly); if (prop.waitOperandsDeviceType) attrs.append("waitOperandsDeviceType", prop.waitOperandsDeviceType); if (prop.waitOperandsSegments) attrs.append("waitOperandsSegments", prop.waitOperandsSegments); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult ParallelOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCombinedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "combined", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDefaultAttrAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps11(attr, "defaultAttr", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getHasWaitDevnumAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps10(attr, "hasWaitDevnum", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNumGangsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "numGangsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNumGangsSegmentsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(attr, "numGangsSegments", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNumWorkersDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "numWorkersDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSelfAttrAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "selfAttr", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVectorLengthDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "vectorLengthDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "waitOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "waitOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOperandsSegmentsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(attr, "waitOperandsSegments", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ParallelOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.combined))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.defaultAttr))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.hasWaitDevnum))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.numGangsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.numGangsSegments))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.numWorkersDeviceType))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.selfAttr))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.vectorLengthDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.waitOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.waitOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.waitOperandsSegments))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void ParallelOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.combined); writer.writeOptionalAttribute(prop.defaultAttr); writer.writeOptionalAttribute(prop.hasWaitDevnum); writer.writeOptionalAttribute(prop.numGangsDeviceType); writer.writeOptionalAttribute(prop.numGangsSegments); writer.writeOptionalAttribute(prop.numWorkersDeviceType); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.selfAttr); writer.writeOptionalAttribute(prop.vectorLengthDeviceType); writer.writeOptionalAttribute(prop.waitOnly); writer.writeOptionalAttribute(prop.waitOperandsDeviceType); writer.writeOptionalAttribute(prop.waitOperandsSegments); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::std::optional< ::mlir::ArrayAttr > ParallelOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ParallelOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> ParallelOp::getWaitOperandsSegments() { auto attr = getWaitOperandsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ParallelOp::getWaitOperandsDeviceType() { auto attr = getWaitOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ParallelOp::getHasWaitDevnum() { auto attr = getHasWaitDevnumAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ParallelOp::getWaitOnly() { auto attr = getWaitOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> ParallelOp::getNumGangsSegments() { auto attr = getNumGangsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ParallelOp::getNumGangsDeviceType() { auto attr = getNumGangsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ParallelOp::getNumWorkersDeviceType() { auto attr = getNumWorkersDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ParallelOp::getVectorLengthDeviceType() { auto attr = getVectorLengthDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } bool ParallelOp::getSelfAttr() { auto attr = getSelfAttrAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::std::optional<::mlir::acc::ClauseDefaultValue> ParallelOp::getDefaultAttr() { auto attr = getDefaultAttrAttr(); return attr ? ::std::optional<::mlir::acc::ClauseDefaultValue>(attr.getValue()) : (::std::nullopt); } bool ParallelOp::getCombined() { auto attr = getCombinedAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void ParallelOp::setWaitOperandsSegments(::std::optional<::llvm::ArrayRef> attrValue) { auto &odsProp = getProperties().waitOperandsSegments; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(*attrValue); else odsProp = nullptr; } void ParallelOp::setNumGangsSegments(::std::optional<::llvm::ArrayRef> attrValue) { auto &odsProp = getProperties().numGangsSegments; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(*attrValue); else odsProp = nullptr; } void ParallelOp::setSelfAttr(bool attrValue) { auto &odsProp = getProperties().selfAttr; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void ParallelOp::setDefaultAttr(::std::optional<::mlir::acc::ClauseDefaultValue> attrValue) { auto &odsProp = getProperties().defaultAttr; if (attrValue) odsProp = ::mlir::acc::ClauseDefaultValueAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void ParallelOp::setCombined(bool attrValue) { auto &odsProp = getProperties().combined; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } ParallelOp ParallelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, mlir::ValueRange numGangs, mlir::ValueRange numWorkers, mlir::ValueRange vectorLength, mlir::ValueRange asyncOperands, mlir::ValueRange waitOperands, mlir::Value ifCond, mlir::Value selfCond, mlir::ValueRange reductionOperands, mlir::ValueRange privateOperands, mlir::ValueRange firstprivateOperands, mlir::ValueRange dataClauseOperands) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(numGangs), std::forward(numWorkers), std::forward(vectorLength), std::forward(asyncOperands), std::forward(waitOperands), std::forward(ifCond), std::forward(selfCond), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ParallelOp ParallelOp::create(::mlir::ImplicitLocOpBuilder &builder, mlir::ValueRange numGangs, mlir::ValueRange numWorkers, mlir::ValueRange vectorLength, mlir::ValueRange asyncOperands, mlir::ValueRange waitOperands, mlir::Value ifCond, mlir::Value selfCond, mlir::ValueRange reductionOperands, mlir::ValueRange privateOperands, mlir::ValueRange firstprivateOperands, mlir::ValueRange dataClauseOperands) { return create(builder, builder.getLoc(), std::forward(numGangs), std::forward(numWorkers), std::forward(vectorLength), std::forward(asyncOperands), std::forward(waitOperands), std::forward(ifCond), std::forward(selfCond), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands)); } void ParallelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); odsState.addOperands(numGangs); odsState.addOperands(numWorkers); odsState.addOperands(vectorLength); if (ifCond) odsState.addOperands(ifCond); if (selfCond) odsState.addOperands(selfCond); odsState.addOperands(reductionOperands); odsState.addOperands(privateOperands); odsState.addOperands(firstprivateOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(asyncOperands.size()), static_cast(waitOperands.size()), static_cast(numGangs.size()), static_cast(numWorkers.size()), static_cast(vectorLength.size()), (ifCond ? 1 : 0), (selfCond ? 1 : 0), static_cast(reductionOperands.size()), static_cast(privateOperands.size()), static_cast(firstprivateOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (numGangsSegments) { odsState.getOrAddProperties().numGangsSegments = numGangsSegments; } if (numGangsDeviceType) { odsState.getOrAddProperties().numGangsDeviceType = numGangsDeviceType; } if (numWorkersDeviceType) { odsState.getOrAddProperties().numWorkersDeviceType = numWorkersDeviceType; } if (vectorLengthDeviceType) { odsState.getOrAddProperties().vectorLengthDeviceType = vectorLengthDeviceType; } if (selfAttr) { odsState.getOrAddProperties().selfAttr = selfAttr; } if (defaultAttr) { odsState.getOrAddProperties().defaultAttr = defaultAttr; } if (combined) { odsState.getOrAddProperties().combined = combined; } (void)odsState.addRegion(); } ParallelOp ParallelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ParallelOp ParallelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { return create(builder, builder.getLoc(), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); } void ParallelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); odsState.addOperands(numGangs); odsState.addOperands(numWorkers); odsState.addOperands(vectorLength); if (ifCond) odsState.addOperands(ifCond); if (selfCond) odsState.addOperands(selfCond); odsState.addOperands(reductionOperands); odsState.addOperands(privateOperands); odsState.addOperands(firstprivateOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(asyncOperands.size()), static_cast(waitOperands.size()), static_cast(numGangs.size()), static_cast(numWorkers.size()), static_cast(vectorLength.size()), (ifCond ? 1 : 0), (selfCond ? 1 : 0), static_cast(reductionOperands.size()), static_cast(privateOperands.size()), static_cast(firstprivateOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (numGangsSegments) { odsState.getOrAddProperties().numGangsSegments = numGangsSegments; } if (numGangsDeviceType) { odsState.getOrAddProperties().numGangsDeviceType = numGangsDeviceType; } if (numWorkersDeviceType) { odsState.getOrAddProperties().numWorkersDeviceType = numWorkersDeviceType; } if (vectorLengthDeviceType) { odsState.getOrAddProperties().vectorLengthDeviceType = vectorLengthDeviceType; } if (selfAttr) { odsState.getOrAddProperties().selfAttr = selfAttr; } if (defaultAttr) { odsState.getOrAddProperties().defaultAttr = defaultAttr; } if (combined) { odsState.getOrAddProperties().combined = combined; } (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ParallelOp ParallelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ParallelOp ParallelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); } void ParallelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); odsState.addOperands(numGangs); odsState.addOperands(numWorkers); odsState.addOperands(vectorLength); if (ifCond) odsState.addOperands(ifCond); if (selfCond) odsState.addOperands(selfCond); odsState.addOperands(reductionOperands); odsState.addOperands(privateOperands); odsState.addOperands(firstprivateOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(asyncOperands.size()), static_cast(waitOperands.size()), static_cast(numGangs.size()), static_cast(numWorkers.size()), static_cast(vectorLength.size()), (ifCond ? 1 : 0), (selfCond ? 1 : 0), static_cast(reductionOperands.size()), static_cast(privateOperands.size()), static_cast(firstprivateOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (numGangsSegments) { odsState.getOrAddProperties().numGangsSegments = numGangsSegments; } if (numGangsDeviceType) { odsState.getOrAddProperties().numGangsDeviceType = numGangsDeviceType; } if (numWorkersDeviceType) { odsState.getOrAddProperties().numWorkersDeviceType = numWorkersDeviceType; } if (vectorLengthDeviceType) { odsState.getOrAddProperties().vectorLengthDeviceType = vectorLengthDeviceType; } if (selfAttr) { odsState.getOrAddProperties().selfAttr = ((selfAttr) ? odsBuilder.getUnitAttr() : nullptr); } if (defaultAttr) { odsState.getOrAddProperties().defaultAttr = defaultAttr; } if (combined) { odsState.getOrAddProperties().combined = ((combined) ? odsBuilder.getUnitAttr() : nullptr); } (void)odsState.addRegion(); } ParallelOp ParallelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ParallelOp ParallelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { return create(builder, builder.getLoc(), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); } void ParallelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); odsState.addOperands(numGangs); odsState.addOperands(numWorkers); odsState.addOperands(vectorLength); if (ifCond) odsState.addOperands(ifCond); if (selfCond) odsState.addOperands(selfCond); odsState.addOperands(reductionOperands); odsState.addOperands(privateOperands); odsState.addOperands(firstprivateOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(asyncOperands.size()), static_cast(waitOperands.size()), static_cast(numGangs.size()), static_cast(numWorkers.size()), static_cast(vectorLength.size()), (ifCond ? 1 : 0), (selfCond ? 1 : 0), static_cast(reductionOperands.size()), static_cast(privateOperands.size()), static_cast(firstprivateOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (numGangsSegments) { odsState.getOrAddProperties().numGangsSegments = numGangsSegments; } if (numGangsDeviceType) { odsState.getOrAddProperties().numGangsDeviceType = numGangsDeviceType; } if (numWorkersDeviceType) { odsState.getOrAddProperties().numWorkersDeviceType = numWorkersDeviceType; } if (vectorLengthDeviceType) { odsState.getOrAddProperties().vectorLengthDeviceType = vectorLengthDeviceType; } if (selfAttr) { odsState.getOrAddProperties().selfAttr = ((selfAttr) ? odsBuilder.getUnitAttr() : nullptr); } if (defaultAttr) { odsState.getOrAddProperties().defaultAttr = defaultAttr; } if (combined) { odsState.getOrAddProperties().combined = ((combined) ? odsBuilder.getUnitAttr() : nullptr); } (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ParallelOp ParallelOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ParallelOp ParallelOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange numGangs, /*optional*/::mlir::DenseI32ArrayAttr numGangsSegments, /*optional*/::mlir::ArrayAttr numGangsDeviceType, ::mlir::ValueRange numWorkers, /*optional*/::mlir::ArrayAttr numWorkersDeviceType, ::mlir::ValueRange vectorLength, /*optional*/::mlir::ArrayAttr vectorLengthDeviceType, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(numGangs), std::forward(numGangsSegments), std::forward(numGangsDeviceType), std::forward(numWorkers), std::forward(numWorkersDeviceType), std::forward(vectorLength), std::forward(vectorLengthDeviceType), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); } void ParallelOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ParallelOp ParallelOp::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__; } ParallelOp ParallelOp::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 ParallelOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ParallelOp ParallelOp::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__; } ParallelOp ParallelOp::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 ParallelOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_combined = getProperties().combined; (void)tblgen_combined; auto tblgen_defaultAttr = getProperties().defaultAttr; (void)tblgen_defaultAttr; auto tblgen_hasWaitDevnum = getProperties().hasWaitDevnum; (void)tblgen_hasWaitDevnum; auto tblgen_numGangsDeviceType = getProperties().numGangsDeviceType; (void)tblgen_numGangsDeviceType; auto tblgen_numGangsSegments = getProperties().numGangsSegments; (void)tblgen_numGangsSegments; auto tblgen_numWorkersDeviceType = getProperties().numWorkersDeviceType; (void)tblgen_numWorkersDeviceType; auto tblgen_selfAttr = getProperties().selfAttr; (void)tblgen_selfAttr; auto tblgen_vectorLengthDeviceType = getProperties().vectorLengthDeviceType; (void)tblgen_vectorLengthDeviceType; auto tblgen_waitOnly = getProperties().waitOnly; (void)tblgen_waitOnly; auto tblgen_waitOperandsDeviceType = getProperties().waitOperandsDeviceType; (void)tblgen_waitOperandsDeviceType; auto tblgen_waitOperandsSegments = getProperties().waitOperandsSegments; (void)tblgen_waitOperandsSegments; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(*this, tblgen_waitOperandsSegments, "waitOperandsSegments"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_waitOperandsDeviceType, "waitOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps10(*this, tblgen_hasWaitDevnum, "hasWaitDevnum"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_waitOnly, "waitOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(*this, tblgen_numGangsSegments, "numGangsSegments"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_numGangsDeviceType, "numGangsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_numWorkersDeviceType, "numWorkersDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_vectorLengthDeviceType, "vectorLengthDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_selfAttr, "selfAttr"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps11(*this, tblgen_defaultAttr, "defaultAttr"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_combined, "combined"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup5 = getODSOperands(5); if (valueGroup5.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup5.size(); } for (auto v : valueGroup5) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup6 = getODSOperands(6); if (valueGroup6.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup6.size(); } for (auto v : valueGroup6) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup7 = getODSOperands(7); for (auto v : valueGroup7) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup8 = getODSOperands(8); for (auto v : valueGroup8) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup9 = getODSOperands(9); for (auto v : valueGroup9) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup10 = getODSOperands(10); for (auto v : valueGroup10) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ParallelOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ParallelOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dataClauseOperandsOperands; ::llvm::SMLoc dataClauseOperandsOperandsLoc; (void)dataClauseOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> dataClauseOperandsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> firstprivateOperandsOperands; ::llvm::SMLoc firstprivateOperandsOperandsLoc; (void)firstprivateOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> firstprivateOperandsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> numGangsOperands; ::llvm::SMLoc numGangsOperandsLoc; (void)numGangsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> numGangsTypes; ::mlir::ArrayAttr numGangsDeviceTypeAttr; ::mlir::DenseI32ArrayAttr numGangsSegmentsAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> numWorkersOperands; ::llvm::SMLoc numWorkersOperandsLoc; (void)numWorkersOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> numWorkersTypes; ::mlir::ArrayAttr numWorkersDeviceTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> privateOperandsOperands; ::llvm::SMLoc privateOperandsOperandsLoc; (void)privateOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> privateOperandsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> vectorLengthOperands; ::llvm::SMLoc vectorLengthOperandsLoc; (void)vectorLengthOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> vectorLengthTypes; ::mlir::ArrayAttr vectorLengthDeviceTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> waitOperandsOperands; ::llvm::SMLoc waitOperandsOperandsLoc; (void)waitOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> waitOperandsTypes; ::mlir::ArrayAttr waitOperandsDeviceTypeAttr; ::mlir::DenseI32ArrayAttr waitOperandsSegmentsAttr; ::mlir::ArrayAttr hasWaitDevnumAttr; ::mlir::ArrayAttr waitOnlyAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> selfCondOperands; ::llvm::SMLoc selfCondOperandsLoc; (void)selfCondOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> reductionOperandsOperands; ::llvm::SMLoc reductionOperandsOperandsLoc; (void)reductionOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> reductionOperandsTypes; std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); if (::mlir::succeeded(parser.parseOptionalKeyword("combined"))) { result.getOrAddProperties().combined = parser.getBuilder().getUnitAttr(); if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseKeyword("loop")) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } bool dataOperandsClause = false; bool asyncClause = false; bool firstprivateClause = false; bool num_gangsClause = false; bool num_workersClause = false; bool privateClause = false; bool vector_lengthClause = false; bool waitClause = false; bool selfClause = false; bool ifClause = false; bool reductionClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("dataOperands"))) { if (dataOperandsClause) { return parser.emitError(parser.getNameLoc()) << "`dataOperands` clause can appear at most once in the expansion of the " "oilist directive"; } dataOperandsClause = true; if (parser.parseLParen()) return ::mlir::failure(); dataClauseOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(dataClauseOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(dataClauseOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("firstprivate"))) { if (firstprivateClause) { return parser.emitError(parser.getNameLoc()) << "`firstprivate` clause can appear at most once in the expansion of the " "oilist directive"; } firstprivateClause = true; if (parser.parseLParen()) return ::mlir::failure(); firstprivateOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(firstprivateOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(firstprivateOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("num_gangs"))) { if (num_gangsClause) { return parser.emitError(parser.getNameLoc()) << "`num_gangs` clause can appear at most once in the expansion of the " "oilist directive"; } num_gangsClause = true; if (parser.parseLParen()) return ::mlir::failure(); { numGangsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseNumGangs(parser, numGangsOperands, numGangsTypes, numGangsDeviceTypeAttr, numGangsSegmentsAttr); if (odsResult) return ::mlir::failure(); if (numGangsDeviceTypeAttr) result.getOrAddProperties().numGangsDeviceType = numGangsDeviceTypeAttr; if (numGangsSegmentsAttr) result.getOrAddProperties().numGangsSegments = numGangsSegmentsAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("num_workers"))) { if (num_workersClause) { return parser.emitError(parser.getNameLoc()) << "`num_workers` clause can appear at most once in the expansion of the " "oilist directive"; } num_workersClause = true; if (parser.parseLParen()) return ::mlir::failure(); { numWorkersOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperands(parser, numWorkersOperands, numWorkersTypes, numWorkersDeviceTypeAttr); if (odsResult) return ::mlir::failure(); if (numWorkersDeviceTypeAttr) result.getOrAddProperties().numWorkersDeviceType = numWorkersDeviceTypeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("private"))) { if (privateClause) { return parser.emitError(parser.getNameLoc()) << "`private` clause can appear at most once in the expansion of the " "oilist directive"; } privateClause = true; if (parser.parseLParen()) return ::mlir::failure(); privateOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(privateOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(privateOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("vector_length"))) { if (vector_lengthClause) { return parser.emitError(parser.getNameLoc()) << "`vector_length` clause can appear at most once in the expansion of the " "oilist directive"; } vector_lengthClause = true; if (parser.parseLParen()) return ::mlir::failure(); { vectorLengthOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperands(parser, vectorLengthOperands, vectorLengthTypes, vectorLengthDeviceTypeAttr); if (odsResult) return ::mlir::failure(); if (vectorLengthDeviceTypeAttr) result.getOrAddProperties().vectorLengthDeviceType = vectorLengthDeviceTypeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("wait"))) { if (waitClause) { return parser.emitError(parser.getNameLoc()) << "`wait` clause can appear at most once in the expansion of the " "oilist directive"; } waitClause = true; { waitOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseWaitClause(parser, waitOperandsOperands, waitOperandsTypes, waitOperandsDeviceTypeAttr, waitOperandsSegmentsAttr, hasWaitDevnumAttr, waitOnlyAttr); if (odsResult) return ::mlir::failure(); if (waitOperandsDeviceTypeAttr) result.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceTypeAttr; if (waitOperandsSegmentsAttr) result.getOrAddProperties().waitOperandsSegments = waitOperandsSegmentsAttr; if (hasWaitDevnumAttr) result.getOrAddProperties().hasWaitDevnum = hasWaitDevnumAttr; if (waitOnlyAttr) result.getOrAddProperties().waitOnly = waitOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("self"))) { if (selfClause) { return parser.emitError(parser.getNameLoc()) << "`self` clause can appear at most once in the expansion of the " "oilist directive"; } selfClause = true; if (parser.parseLParen()) return ::mlir::failure(); { selfCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); selfCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("reduction"))) { if (reductionClause) { return parser.emitError(parser.getNameLoc()) << "`reduction` clause can appear at most once in the expansion of the " "oilist directive"; } reductionClause = true; if (parser.parseLParen()) return ::mlir::failure(); reductionOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(reductionOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(reductionOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseRegion(*regionRegion)) return ::mlir::failure(); { 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(); } result.addRegion(std::move(regionRegion)); ::llvm::copy(::llvm::ArrayRef({static_cast(asyncOperandsOperands.size()), static_cast(waitOperandsOperands.size()), static_cast(numGangsOperands.size()), static_cast(numWorkersOperands.size()), static_cast(vectorLengthOperands.size()), static_cast(ifCondOperands.size()), static_cast(selfCondOperands.size()), static_cast(reductionOperandsOperands.size()), static_cast(privateOperandsOperands.size()), static_cast(firstprivateOperandsOperands.size()), static_cast(dataClauseOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(waitOperandsOperands, waitOperandsTypes, waitOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(numGangsOperands, numGangsTypes, numGangsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(numWorkersOperands, numWorkersTypes, numWorkersOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(vectorLengthOperands, vectorLengthTypes, vectorLengthOperandsLoc, result.operands)) return ::mlir::failure(); if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } if (!selfCondOperands.empty()) { if (parser.resolveOperands(selfCondOperands, odsBuildableType0, selfCondOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(reductionOperandsOperands, reductionOperandsTypes, reductionOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(privateOperandsOperands, privateOperandsTypes, privateOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(firstprivateOperandsOperands, firstprivateOperandsTypes, firstprivateOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(dataClauseOperandsOperands, dataClauseOperandsTypes, dataClauseOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ParallelOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if ((getCombinedAttr() && getCombinedAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "combined"; _odsPrinter << "("; _odsPrinter << "loop"; _odsPrinter << ")"; } if (false || getDataClauseOperands().size()) { _odsPrinter << ' ' << "dataOperands"; _odsPrinter << "("; _odsPrinter << getDataClauseOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getDataClauseOperands().getTypes(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || getFirstprivateOperands().size()) { _odsPrinter << ' ' << "firstprivate"; _odsPrinter << "("; _odsPrinter << getFirstprivateOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getFirstprivateOperands().getTypes(); _odsPrinter << ")"; } if (false || getNumGangs().size() || (getNumGangsDeviceTypeAttr()) || (getNumGangsSegmentsAttr())) { _odsPrinter << ' ' << "num_gangs"; _odsPrinter << "("; printNumGangs(_odsPrinter, *this, getNumGangs(), getNumGangs().getTypes(), getNumGangsDeviceTypeAttr(), getNumGangsSegmentsAttr()); _odsPrinter << ")"; } if (false || getNumWorkers().size() || (getNumWorkersDeviceTypeAttr())) { _odsPrinter << ' ' << "num_workers"; _odsPrinter << "("; printDeviceTypeOperands(_odsPrinter, *this, getNumWorkers(), getNumWorkers().getTypes(), getNumWorkersDeviceTypeAttr()); _odsPrinter << ")"; } if (false || getPrivateOperands().size()) { _odsPrinter << ' ' << "private"; _odsPrinter << "("; _odsPrinter << getPrivateOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getPrivateOperands().getTypes(); _odsPrinter << ")"; } if (false || getVectorLength().size() || (getVectorLengthDeviceTypeAttr())) { _odsPrinter << ' ' << "vector_length"; _odsPrinter << "("; printDeviceTypeOperands(_odsPrinter, *this, getVectorLength(), getVectorLength().getTypes(), getVectorLengthDeviceTypeAttr()); _odsPrinter << ")"; } if (false || getWaitOperands().size() || (getWaitOperandsDeviceTypeAttr()) || (getWaitOperandsSegmentsAttr()) || (getHasWaitDevnumAttr()) || (getWaitOnlyAttr())) { _odsPrinter << ' ' << "wait"; printWaitClause(_odsPrinter, *this, getWaitOperands(), getWaitOperands().getTypes(), getWaitOperandsDeviceTypeAttr(), getWaitOperandsSegmentsAttr(), getHasWaitDevnumAttr(), getWaitOnlyAttr()); } if (false || getSelfCond()) { _odsPrinter << ' ' << "self"; _odsPrinter << "("; if (::mlir::Value value = getSelfCond()) _odsPrinter << value; _odsPrinter << ")"; } if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } if (false || getReductionOperands().size()) { _odsPrinter << ' ' << "reduction"; _odsPrinter << "("; _odsPrinter << getReductionOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getReductionOperands().getTypes(); _odsPrinter << ")"; } _odsPrinter << ' '; _odsPrinter.printRegion(getRegion()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("combined"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("numGangsDeviceType"); elidedAttrs.push_back("numGangsSegments"); elidedAttrs.push_back("numWorkersDeviceType"); elidedAttrs.push_back("vectorLengthDeviceType"); elidedAttrs.push_back("waitOperandsDeviceType"); elidedAttrs.push_back("waitOperandsSegments"); elidedAttrs.push_back("hasWaitDevnum"); elidedAttrs.push_back("waitOnly"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getSelfAttrAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("selfAttr"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getCombinedAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("combined"); } _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } void ParallelOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::acc::ConstructResource::get()); effects.emplace_back(::mlir::MemoryEffects::Read::get(), 0, false, ::mlir::acc::CurrentDeviceIdResource::get()); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::ParallelOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::ParallelOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::PredicateRegionOp definitions //===----------------------------------------------------------------------===// namespace detail { PredicateRegionOpGenericAdaptorBase::PredicateRegionOpGenericAdaptorBase(PredicateRegionOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail PredicateRegionOpAdaptor::PredicateRegionOpAdaptor(PredicateRegionOp op) : PredicateRegionOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult PredicateRegionOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult PredicateRegionOp::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 PredicateRegionOp::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 PredicateRegionOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional PredicateRegionOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void PredicateRegionOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void PredicateRegionOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult PredicateRegionOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void PredicateRegionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { (void)odsState.addRegion(); } PredicateRegionOp PredicateRegionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PredicateRegionOp PredicateRegionOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void PredicateRegionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } PredicateRegionOp PredicateRegionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PredicateRegionOp PredicateRegionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void PredicateRegionOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } PredicateRegionOp PredicateRegionOp::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__; } PredicateRegionOp PredicateRegionOp::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 PredicateRegionOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } PredicateRegionOp PredicateRegionOp::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__; } PredicateRegionOp PredicateRegionOp::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 PredicateRegionOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult PredicateRegionOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult PredicateRegionOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); if (parser.parseRegion(*regionRegion)) 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.addRegion(std::move(regionRegion)); return ::mlir::success(); } void PredicateRegionOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printRegion(getRegion()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::PredicateRegionOp) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::PresentOp definitions //===----------------------------------------------------------------------===// namespace detail { PresentOpGenericAdaptorBase::PresentOpGenericAdaptorBase(PresentOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair PresentOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type PresentOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > PresentOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > PresentOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr PresentOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause PresentOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr PresentOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool PresentOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr PresentOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool PresentOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr PresentOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier PresentOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > PresentOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > PresentOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail PresentOpAdaptor::PresentOpAdaptor(PresentOp op) : PresentOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult PresentOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.present' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.present' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.present' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.present' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.present' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.present' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.present' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.present' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.present' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.present' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair PresentOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange PresentOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange PresentOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange PresentOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult PresentOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute PresentOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code PresentOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional PresentOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void PresentOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void PresentOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult PresentOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult PresentOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void PresentOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type PresentOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > PresentOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > PresentOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause PresentOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool PresentOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool PresentOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier PresentOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > PresentOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > PresentOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void PresentOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void PresentOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void PresentOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void PresentOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void PresentOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void PresentOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void PresentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } PresentOp PresentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PresentOp PresentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void PresentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } PresentOp PresentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PresentOp PresentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void PresentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } PresentOp PresentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PresentOp PresentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void PresentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } PresentOp PresentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PresentOp PresentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void PresentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } PresentOp PresentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PresentOp PresentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void PresentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } PresentOp PresentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PresentOp PresentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void PresentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } PresentOp PresentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PresentOp PresentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void PresentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } PresentOp PresentOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PresentOp PresentOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void PresentOp::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."); } } PresentOp PresentOp::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__; } PresentOp PresentOp::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 PresentOp::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); } PresentOp PresentOp::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__; } PresentOp PresentOp::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 PresentOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_present); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult PresentOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult PresentOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult PresentOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void PresentOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_present))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::PresentOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::PresentOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::PrivateLocalOp definitions //===----------------------------------------------------------------------===// namespace detail { PrivateLocalOpGenericAdaptorBase::PrivateLocalOpGenericAdaptorBase(PrivateLocalOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail PrivateLocalOpAdaptor::PrivateLocalOpAdaptor(PrivateLocalOp op) : PrivateLocalOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult PrivateLocalOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult PrivateLocalOp::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 PrivateLocalOp::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 PrivateLocalOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional PrivateLocalOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void PrivateLocalOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void PrivateLocalOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult PrivateLocalOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void PrivateLocalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType, ::mlir::Value privatized) { odsState.addOperands(privatized); odsState.addTypes(resultType); } PrivateLocalOp PrivateLocalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type resultType, ::mlir::Value privatized) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(privatized)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivateLocalOp PrivateLocalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type resultType, ::mlir::Value privatized) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(privatized)); } void PrivateLocalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value privatized) { odsState.addOperands(privatized); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } PrivateLocalOp PrivateLocalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value privatized) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(privatized)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivateLocalOp PrivateLocalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value privatized) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(privatized)); } void PrivateLocalOp::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); } PrivateLocalOp PrivateLocalOp::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__; } PrivateLocalOp PrivateLocalOp::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 PrivateLocalOp::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); } PrivateLocalOp PrivateLocalOp::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__; } PrivateLocalOp PrivateLocalOp::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 PrivateLocalOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps16(*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_OpenACCOps3(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult PrivateLocalOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult PrivateLocalOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand privatizedRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> privatizedOperands(&privatizedRawOperand, 1); ::llvm::SMLoc privatizedOperandsLoc; (void)privatizedOperandsLoc; ::llvm::ArrayRef<::mlir::Type> allOperandTypes; ::llvm::ArrayRef<::mlir::Type> allResultTypes; privatizedOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(privatizedRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); ::mlir::FunctionType allOperand__allResult_functionType; if (parser.parseType(allOperand__allResult_functionType)) return ::mlir::failure(); allOperandTypes = allOperand__allResult_functionType.getInputs(); allResultTypes = allOperand__allResult_functionType.getResults(); result.addTypes(allResultTypes); if (parser.resolveOperands(privatizedOperands, allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void PrivateLocalOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getPrivatized(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); } void PrivateLocalOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::PrivateLocalOp) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::PrivateOp definitions //===----------------------------------------------------------------------===// namespace detail { PrivateOpGenericAdaptorBase::PrivateOpGenericAdaptorBase(PrivateOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair PrivateOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type PrivateOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > PrivateOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > PrivateOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr PrivateOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause PrivateOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr PrivateOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool PrivateOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr PrivateOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool PrivateOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr PrivateOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier PrivateOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > PrivateOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > PrivateOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail PrivateOpAdaptor::PrivateOpAdaptor(PrivateOp op) : PrivateOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult PrivateOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.private' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.private' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.private' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.private' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.private' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.private' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.private' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.private' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.private' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.private' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair PrivateOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange PrivateOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange PrivateOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange PrivateOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult PrivateOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute PrivateOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code PrivateOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional PrivateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void PrivateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void PrivateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult PrivateOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult PrivateOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void PrivateOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type PrivateOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > PrivateOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > PrivateOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause PrivateOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool PrivateOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool PrivateOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier PrivateOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > PrivateOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > PrivateOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void PrivateOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void PrivateOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void PrivateOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void PrivateOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void PrivateOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void PrivateOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void PrivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } PrivateOp PrivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivateOp PrivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void PrivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } PrivateOp PrivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivateOp PrivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void PrivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } PrivateOp PrivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivateOp PrivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void PrivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } PrivateOp PrivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivateOp PrivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void PrivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } PrivateOp PrivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivateOp PrivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void PrivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } PrivateOp PrivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivateOp PrivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void PrivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } PrivateOp PrivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivateOp PrivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void PrivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } PrivateOp PrivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivateOp PrivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void PrivateOp::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."); } } PrivateOp PrivateOp::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__; } PrivateOp PrivateOp::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 PrivateOp::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); } PrivateOp PrivateOp::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__; } PrivateOp PrivateOp::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 PrivateOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_private); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult PrivateOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult PrivateOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult PrivateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void PrivateOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_private))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::PrivateOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::PrivateOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::PrivateRecipeOp definitions //===----------------------------------------------------------------------===// namespace detail { PrivateRecipeOpGenericAdaptorBase::PrivateRecipeOpGenericAdaptorBase(PrivateRecipeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::llvm::StringRef PrivateRecipeOpGenericAdaptorBase::getSymName() { auto attr = getSymNameAttr(); return attr.getValue(); } ::mlir::Type PrivateRecipeOpGenericAdaptorBase::getType() { auto attr = getTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } } // namespace detail PrivateRecipeOpAdaptor::PrivateRecipeOpAdaptor(PrivateRecipeOp op) : PrivateRecipeOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult PrivateRecipeOpAdaptor::verify(::mlir::Location loc) { auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; if (!tblgen_sym_name) return emitError(loc, "'acc.private.recipe' op requires attribute 'sym_name'"); auto tblgen_type = getProperties().type; (void)tblgen_type; if (!tblgen_type) return emitError(loc, "'acc.private.recipe' op requires attribute 'type'"); if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name)))) return emitError(loc, "'acc.private.recipe' op attribute 'sym_name' failed to satisfy constraint: string attribute"); if (tblgen_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_type).getValue()))) && ((true)))) return emitError(loc, "'acc.private.recipe' op attribute 'type' failed to satisfy constraint: any type attribute"); return ::mlir::success(); } ::llvm::LogicalResult PrivateRecipeOp::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.type; auto attr = dict.get("type"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `type` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute PrivateRecipeOp::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.type; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("type", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code PrivateRecipeOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.sym_name.getAsOpaquePointer()), llvm::hash_value(prop.type.getAsOpaquePointer())); } std::optional PrivateRecipeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "sym_name") return prop.sym_name; if (name == "type") return prop.type; return std::nullopt; } void PrivateRecipeOp::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 == "type") { prop.type = ::llvm::dyn_cast_or_null>(value); return; } } void PrivateRecipeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.sym_name) attrs.append("sym_name", prop.sym_name); if (prop.type) attrs.append("type", prop.type); } ::llvm::LogicalResult PrivateRecipeOp::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_OpenACCOps6(attr, "sym_name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "type", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult PrivateRecipeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.sym_name))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.type))) return ::mlir::failure(); return ::mlir::success(); } void PrivateRecipeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.sym_name); writer.writeAttribute(prop.type); } ::llvm::StringRef PrivateRecipeOp::getSymName() { auto attr = getSymNameAttr(); return attr.getValue(); } ::mlir::Type PrivateRecipeOp::getType() { auto attr = getTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } void PrivateRecipeOp::setSymName(::llvm::StringRef attrValue) { getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue); } void PrivateRecipeOp::setType(::mlir::Type attrValue) { getProperties().type = ::mlir::TypeAttr::get(attrValue); } void PrivateRecipeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) { odsState.getOrAddProperties().sym_name = sym_name; odsState.getOrAddProperties().type = type; (void)odsState.addRegion(); (void)odsState.addRegion(); } PrivateRecipeOp PrivateRecipeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sym_name), std::forward(type)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivateRecipeOp PrivateRecipeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) { return create(builder, builder.getLoc(), std::forward(sym_name), std::forward(type)); } void PrivateRecipeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) { odsState.getOrAddProperties().sym_name = sym_name; odsState.getOrAddProperties().type = type; (void)odsState.addRegion(); (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } PrivateRecipeOp PrivateRecipeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(sym_name), std::forward(type)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivateRecipeOp PrivateRecipeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(sym_name), std::forward(type)); } void PrivateRecipeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, ::mlir::Type type) { odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); odsState.getOrAddProperties().type = ::mlir::TypeAttr::get(type); (void)odsState.addRegion(); (void)odsState.addRegion(); } PrivateRecipeOp PrivateRecipeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef sym_name, ::mlir::Type type) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sym_name), std::forward(type)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivateRecipeOp PrivateRecipeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llvm::StringRef sym_name, ::mlir::Type type) { return create(builder, builder.getLoc(), std::forward(sym_name), std::forward(type)); } void PrivateRecipeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type) { odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); odsState.getOrAddProperties().type = ::mlir::TypeAttr::get(type); (void)odsState.addRegion(); (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } PrivateRecipeOp PrivateRecipeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(sym_name), std::forward(type)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivateRecipeOp PrivateRecipeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(sym_name), std::forward(type)); } void PrivateRecipeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 2; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } PrivateRecipeOp PrivateRecipeOp::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__; } PrivateRecipeOp PrivateRecipeOp::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 PrivateRecipeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); for (unsigned i = 0; i != 2; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } PrivateRecipeOp PrivateRecipeOp::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__; } PrivateRecipeOp PrivateRecipeOp::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 PrivateRecipeOp::verifyInvariantsImpl() { auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'"); auto tblgen_type = getProperties().type; (void)tblgen_type; if (!tblgen_type) return emitOpError("requires attribute 'type'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_sym_name, "sym_name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_type, "type"))) return ::mlir::failure(); { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "initRegion", index++))) return ::mlir::failure(); for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "destroyRegion", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult PrivateRecipeOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult PrivateRecipeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::StringAttr sym_nameAttr; ::mlir::TypeAttr typeAttr; std::unique_ptr<::mlir::Region> initRegionRegion = std::make_unique<::mlir::Region>(); std::unique_ptr<::mlir::Region> destroyRegionRegion = std::make_unique<::mlir::Region>(); if (parser.parseSymbolName(sym_nameAttr)) return ::mlir::failure(); if (sym_nameAttr) result.getOrAddProperties().sym_name = sym_nameAttr; if (parser.parseColon()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(typeAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (typeAttr) result.getOrAddProperties().type = typeAttr; { 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.parseKeyword("init")) return ::mlir::failure(); if (parser.parseRegion(*initRegionRegion)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("destroy"))) { if (parser.parseRegion(*destroyRegionRegion)) return ::mlir::failure(); } result.addRegion(std::move(initRegionRegion)); result.addRegion(std::move(destroyRegionRegion)); return ::mlir::success(); } void PrivateRecipeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printSymbolName(getSymNameAttr().getValue()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getTypeAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("sym_name"); elidedAttrs.push_back("type"); _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << "init"; _odsPrinter << ' '; _odsPrinter.printRegion(getInitRegion()); if (!getDestroyRegion().empty()) { _odsPrinter << ' ' << "destroy"; _odsPrinter << ' '; _odsPrinter.printRegion(getDestroyRegion()); } } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::PrivateRecipeOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::PrivateRecipeOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::PrivatizeOp definitions //===----------------------------------------------------------------------===// namespace detail { PrivatizeOpGenericAdaptorBase::PrivatizeOpGenericAdaptorBase(PrivatizeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair PrivatizeOpGenericAdaptorBase::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}; } ::std::optional<::mlir::acc::GPUParallelDimsAttr> PrivatizeOpGenericAdaptorBase::getParDims() { auto attr = getParDimsAttr(); return attr ? ::std::optional<::mlir::acc::GPUParallelDimsAttr>(::llvm::cast<::mlir::acc::GPUParallelDimsAttr>(attr)) : (::std::nullopt); } } // namespace detail PrivatizeOpAdaptor::PrivatizeOpAdaptor(PrivatizeOp op) : PrivatizeOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult PrivatizeOpAdaptor::verify(::mlir::Location loc) { auto tblgen_par_dims = getProperties().par_dims; (void)tblgen_par_dims; if (tblgen_par_dims && !((::llvm::isa<::mlir::acc::GPUParallelDimsAttr>(tblgen_par_dims)))) return emitError(loc, "'acc.privatize' op attribute 'par_dims' failed to satisfy constraint: List of GPU parallel dimensions for use in OpenACC parallelism assignment."); return ::mlir::success(); } std::pair PrivatizeOp::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 PrivatizeOp::getDynamicSizesMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult PrivatizeOp::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.par_dims; auto attr = dict.get("par_dims"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `par_dims` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute PrivatizeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.par_dims; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("par_dims", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code PrivatizeOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.par_dims.getAsOpaquePointer())); } std::optional PrivatizeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "par_dims") return prop.par_dims; return std::nullopt; } void PrivatizeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "par_dims") { prop.par_dims = ::llvm::dyn_cast_or_null>(value); return; } } void PrivatizeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.par_dims) attrs.append("par_dims", prop.par_dims); } ::llvm::LogicalResult PrivatizeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getParDimsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps19(attr, "par_dims", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult PrivatizeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.par_dims))) return ::mlir::failure(); return ::mlir::success(); } void PrivatizeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.par_dims); } ::std::optional<::mlir::acc::GPUParallelDimsAttr> PrivatizeOp::getParDims() { auto attr = getParDimsAttr(); return attr ? ::std::optional<::mlir::acc::GPUParallelDimsAttr>(::llvm::cast<::mlir::acc::GPUParallelDimsAttr>(attr)) : (::std::nullopt); } void PrivatizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType, ::mlir::ValueRange dynamicSizes) { odsState.addTypes(resultType); odsState.addOperands(dynamicSizes); } PrivatizeOp PrivatizeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type resultType, ::mlir::ValueRange dynamicSizes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultType), std::forward(dynamicSizes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivatizeOp PrivatizeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type resultType, ::mlir::ValueRange dynamicSizes) { return create(builder, builder.getLoc(), std::forward(resultType), std::forward(dynamicSizes)); } void PrivatizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange dynamicSizes, /*optional*/::mlir::acc::GPUParallelDimsAttr par_dims) { odsState.addOperands(dynamicSizes); if (par_dims) { odsState.getOrAddProperties().par_dims = par_dims; } odsState.addTypes(result); } PrivatizeOp PrivatizeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::ValueRange dynamicSizes, /*optional*/::mlir::acc::GPUParallelDimsAttr par_dims) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(dynamicSizes), std::forward(par_dims)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivatizeOp PrivatizeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::ValueRange dynamicSizes, /*optional*/::mlir::acc::GPUParallelDimsAttr par_dims) { return create(builder, builder.getLoc(), std::forward(result), std::forward(dynamicSizes), std::forward(par_dims)); } void PrivatizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dynamicSizes, /*optional*/::mlir::acc::GPUParallelDimsAttr par_dims) { odsState.addOperands(dynamicSizes); if (par_dims) { odsState.getOrAddProperties().par_dims = par_dims; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } PrivatizeOp PrivatizeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dynamicSizes, /*optional*/::mlir::acc::GPUParallelDimsAttr par_dims) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(dynamicSizes), std::forward(par_dims)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } PrivatizeOp PrivatizeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dynamicSizes, /*optional*/::mlir::acc::GPUParallelDimsAttr par_dims) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(dynamicSizes), std::forward(par_dims)); } void PrivatizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } PrivatizeOp PrivatizeOp::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__; } PrivatizeOp PrivatizeOp::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 PrivatizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } PrivatizeOp PrivatizeOp::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__; } PrivatizeOp PrivatizeOp::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 PrivatizeOp::verifyInvariantsImpl() { auto tblgen_par_dims = getProperties().par_dims; (void)tblgen_par_dims; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps19(*this, tblgen_par_dims, "par_dims"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps8(*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_OpenACCOps16(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult PrivatizeOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult PrivatizeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dynamicSizesOperands; ::llvm::SMLoc dynamicSizesOperandsLoc; (void)dynamicSizesOperandsLoc; ::mlir::acc::GPUParallelDimsAttr par_dimsAttr; ::llvm::ArrayRef<::mlir::Type> allOperandTypes; ::llvm::ArrayRef<::mlir::Type> allResultTypes; if (::mlir::succeeded(parser.parseOptionalLParen())) { dynamicSizesOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(dynamicSizesOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalLSquare())) { if (parser.parseAttribute(par_dimsAttr, ::mlir::Type{})) return ::mlir::failure(); if (par_dimsAttr) result.getOrAddProperties().par_dims = par_dimsAttr; if (parser.parseRSquare()) return ::mlir::failure(); } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); ::mlir::FunctionType allOperand__allResult_functionType; if (parser.parseType(allOperand__allResult_functionType)) return ::mlir::failure(); allOperandTypes = allOperand__allResult_functionType.getInputs(); allResultTypes = allOperand__allResult_functionType.getResults(); result.addTypes(allResultTypes); if (parser.resolveOperands(dynamicSizesOperands, allOperandTypes, parser.getNameLoc(), result.operands)) return ::mlir::failure(); return ::mlir::success(); } void PrivatizeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (!getDynamicSizes().empty()) { _odsPrinter << "("; _odsPrinter << getDynamicSizes(); _odsPrinter << ")"; } if (getParDimsAttr()) { _odsPrinter << ' ' << "["; _odsPrinter.printAttribute(getParDimsAttr()); _odsPrinter << "]"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("par_dims"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::PrivatizeOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::PrivatizeOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::ReductionAccumulateOp definitions //===----------------------------------------------------------------------===// namespace detail { ReductionAccumulateOpGenericAdaptorBase::ReductionAccumulateOpGenericAdaptorBase(ReductionAccumulateOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::acc::ReductionOperator ReductionAccumulateOpGenericAdaptorBase::getReductionOperator() { auto attr = getReductionOperatorAttr(); return attr.getValue(); } ::mlir::acc::GPUParallelDimsAttr ReductionAccumulateOpGenericAdaptorBase::getParDims() { auto attr = getParDimsAttr(); return ::llvm::cast<::mlir::acc::GPUParallelDimsAttr>(attr); } } // namespace detail ReductionAccumulateOpAdaptor::ReductionAccumulateOpAdaptor(ReductionAccumulateOp op) : ReductionAccumulateOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ReductionAccumulateOpAdaptor::verify(::mlir::Location loc) { auto tblgen_par_dims = getProperties().par_dims; (void)tblgen_par_dims; if (!tblgen_par_dims) return emitError(loc, "'acc.reduction_accumulate' op requires attribute 'par_dims'"); auto tblgen_reductionOperator = getProperties().reductionOperator; (void)tblgen_reductionOperator; if (!tblgen_reductionOperator) return emitError(loc, "'acc.reduction_accumulate' op requires attribute 'reductionOperator'"); if (tblgen_reductionOperator && !((::llvm::isa<::mlir::acc::ReductionOperatorAttr>(tblgen_reductionOperator)))) return emitError(loc, "'acc.reduction_accumulate' op attribute 'reductionOperator' failed to satisfy constraint: built-in reduction operations supported by OpenACC"); if (tblgen_par_dims && !((::llvm::isa<::mlir::acc::GPUParallelDimsAttr>(tblgen_par_dims)))) return emitError(loc, "'acc.reduction_accumulate' op attribute 'par_dims' failed to satisfy constraint: List of GPU parallel dimensions for use in OpenACC parallelism assignment."); return ::mlir::success(); } ::llvm::LogicalResult ReductionAccumulateOp::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.par_dims; auto attr = dict.get("par_dims"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `par_dims` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.reductionOperator; auto attr = dict.get("reductionOperator"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `reductionOperator` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ReductionAccumulateOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.par_dims; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("par_dims", propStorage)); } { const auto &propStorage = prop.reductionOperator; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("reductionOperator", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ReductionAccumulateOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.par_dims.getAsOpaquePointer()), llvm::hash_value(prop.reductionOperator.getAsOpaquePointer())); } std::optional ReductionAccumulateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "par_dims") return prop.par_dims; if (name == "reductionOperator") return prop.reductionOperator; return std::nullopt; } void ReductionAccumulateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "par_dims") { prop.par_dims = ::llvm::dyn_cast_or_null>(value); return; } if (name == "reductionOperator") { prop.reductionOperator = ::llvm::dyn_cast_or_null>(value); return; } } void ReductionAccumulateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.par_dims) attrs.append("par_dims", prop.par_dims); if (prop.reductionOperator) attrs.append("reductionOperator", prop.reductionOperator); } ::llvm::LogicalResult ReductionAccumulateOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getParDimsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps19(attr, "par_dims", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getReductionOperatorAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps20(attr, "reductionOperator", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ReductionAccumulateOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.par_dims))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.reductionOperator))) return ::mlir::failure(); return ::mlir::success(); } void ReductionAccumulateOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.par_dims); writer.writeAttribute(prop.reductionOperator); } ::mlir::acc::ReductionOperator ReductionAccumulateOp::getReductionOperator() { auto attr = getReductionOperatorAttr(); return attr.getValue(); } ::mlir::acc::GPUParallelDimsAttr ReductionAccumulateOp::getParDims() { auto attr = getParDimsAttr(); return ::llvm::cast<::mlir::acc::GPUParallelDimsAttr>(attr); } void ReductionAccumulateOp::setReductionOperator(::mlir::acc::ReductionOperator attrValue) { getProperties().reductionOperator = ::mlir::acc::ReductionOperatorAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ReductionAccumulateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value value, ::mlir::Value memref, ::mlir::acc::ReductionOperatorAttr reductionOperator, ::mlir::acc::GPUParallelDimsAttr par_dims) { odsState.addOperands(value); odsState.addOperands(memref); odsState.getOrAddProperties().reductionOperator = reductionOperator; odsState.getOrAddProperties().par_dims = par_dims; } ReductionAccumulateOp ReductionAccumulateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value value, ::mlir::Value memref, ::mlir::acc::ReductionOperatorAttr reductionOperator, ::mlir::acc::GPUParallelDimsAttr par_dims) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(value), std::forward(memref), std::forward(reductionOperator), std::forward(par_dims)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionAccumulateOp ReductionAccumulateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value value, ::mlir::Value memref, ::mlir::acc::ReductionOperatorAttr reductionOperator, ::mlir::acc::GPUParallelDimsAttr par_dims) { return create(builder, builder.getLoc(), std::forward(value), std::forward(memref), std::forward(reductionOperator), std::forward(par_dims)); } void ReductionAccumulateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value memref, ::mlir::acc::ReductionOperatorAttr reductionOperator, ::mlir::acc::GPUParallelDimsAttr par_dims) { odsState.addOperands(value); odsState.addOperands(memref); odsState.getOrAddProperties().reductionOperator = reductionOperator; odsState.getOrAddProperties().par_dims = par_dims; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReductionAccumulateOp ReductionAccumulateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value memref, ::mlir::acc::ReductionOperatorAttr reductionOperator, ::mlir::acc::GPUParallelDimsAttr par_dims) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(value), std::forward(memref), std::forward(reductionOperator), std::forward(par_dims)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionAccumulateOp ReductionAccumulateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value memref, ::mlir::acc::ReductionOperatorAttr reductionOperator, ::mlir::acc::GPUParallelDimsAttr par_dims) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(value), std::forward(memref), std::forward(reductionOperator), std::forward(par_dims)); } void ReductionAccumulateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value value, ::mlir::Value memref, ::mlir::acc::ReductionOperator reductionOperator, ::mlir::acc::GPUParallelDimsAttr par_dims) { odsState.addOperands(value); odsState.addOperands(memref); odsState.getOrAddProperties().reductionOperator = ::mlir::acc::ReductionOperatorAttr::get(odsBuilder.getContext(), reductionOperator); odsState.getOrAddProperties().par_dims = par_dims; } ReductionAccumulateOp ReductionAccumulateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value value, ::mlir::Value memref, ::mlir::acc::ReductionOperator reductionOperator, ::mlir::acc::GPUParallelDimsAttr par_dims) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(value), std::forward(memref), std::forward(reductionOperator), std::forward(par_dims)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionAccumulateOp ReductionAccumulateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value value, ::mlir::Value memref, ::mlir::acc::ReductionOperator reductionOperator, ::mlir::acc::GPUParallelDimsAttr par_dims) { return create(builder, builder.getLoc(), std::forward(value), std::forward(memref), std::forward(reductionOperator), std::forward(par_dims)); } void ReductionAccumulateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value memref, ::mlir::acc::ReductionOperator reductionOperator, ::mlir::acc::GPUParallelDimsAttr par_dims) { odsState.addOperands(value); odsState.addOperands(memref); odsState.getOrAddProperties().reductionOperator = ::mlir::acc::ReductionOperatorAttr::get(odsBuilder.getContext(), reductionOperator); odsState.getOrAddProperties().par_dims = par_dims; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReductionAccumulateOp ReductionAccumulateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value memref, ::mlir::acc::ReductionOperator reductionOperator, ::mlir::acc::GPUParallelDimsAttr par_dims) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(value), std::forward(memref), std::forward(reductionOperator), std::forward(par_dims)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionAccumulateOp ReductionAccumulateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value memref, ::mlir::acc::ReductionOperator reductionOperator, ::mlir::acc::GPUParallelDimsAttr par_dims) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(value), std::forward(memref), std::forward(reductionOperator), std::forward(par_dims)); } void ReductionAccumulateOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ReductionAccumulateOp ReductionAccumulateOp::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__; } ReductionAccumulateOp ReductionAccumulateOp::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 ReductionAccumulateOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ReductionAccumulateOp ReductionAccumulateOp::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__; } ReductionAccumulateOp ReductionAccumulateOp::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 ReductionAccumulateOp::verifyInvariantsImpl() { auto tblgen_par_dims = getProperties().par_dims; (void)tblgen_par_dims; if (!tblgen_par_dims) return emitOpError("requires attribute 'par_dims'"); auto tblgen_reductionOperator = getProperties().reductionOperator; (void)tblgen_reductionOperator; if (!tblgen_reductionOperator) return emitOpError("requires attribute 'reductionOperator'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps20(*this, tblgen_reductionOperator, "reductionOperator"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps19(*this, tblgen_par_dims, "par_dims"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps17(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps2(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ReductionAccumulateOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ReductionAccumulateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand valueRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueOperands(&valueRawOperand, 1); ::llvm::SMLoc valueOperandsLoc; (void)valueOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand memrefRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> memrefOperands(&memrefRawOperand, 1); ::llvm::SMLoc memrefOperandsLoc; (void)memrefOperandsLoc; ::mlir::acc::ReductionOperatorAttr reductionOperatorAttr; ::mlir::Type valueRawType{}; ::llvm::ArrayRef<::mlir::Type> valueTypes(&valueRawType, 1); ::mlir::Type memrefRawType{}; ::llvm::ArrayRef<::mlir::Type> memrefTypes(&memrefRawType, 1); valueOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(valueRawOperand)) return ::mlir::failure(); if (parser.parseKeyword("to")) return ::mlir::failure(); memrefOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(memrefRawOperand)) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(reductionOperatorAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (reductionOperatorAttr) result.getOrAddProperties().reductionOperator = reductionOperatorAttr; if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); valueRawType = type; } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::acc::PointerLikeType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); memrefRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.resolveOperands(valueOperands, valueTypes, valueOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(memrefOperands, memrefTypes, memrefOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ReductionAccumulateOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getValue(); _odsPrinter << ' ' << "to"; _odsPrinter << ' '; _odsPrinter << getMemref(); _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getReductionOperatorAttr()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getValue().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getMemref().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::acc::PointerLikeType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("reductionOperator"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } void ReductionAccumulateOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { { auto valueRange = getODSOperandIndexAndLength(1); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Read::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get()); } } { auto valueRange = getODSOperandIndexAndLength(1); for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get()); } } } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::ReductionAccumulateOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::ReductionAccumulateOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::ReductionCombineOp definitions //===----------------------------------------------------------------------===// namespace detail { ReductionCombineOpGenericAdaptorBase::ReductionCombineOpGenericAdaptorBase(ReductionCombineOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::acc::ReductionOperator ReductionCombineOpGenericAdaptorBase::getReductionOperator() { auto attr = getReductionOperatorAttr(); return attr.getValue(); } } // namespace detail ReductionCombineOpAdaptor::ReductionCombineOpAdaptor(ReductionCombineOp op) : ReductionCombineOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ReductionCombineOpAdaptor::verify(::mlir::Location loc) { auto tblgen_reductionOperator = getProperties().reductionOperator; (void)tblgen_reductionOperator; if (!tblgen_reductionOperator) return emitError(loc, "'acc.reduction_combine' op requires attribute 'reductionOperator'"); if (tblgen_reductionOperator && !((::llvm::isa<::mlir::acc::ReductionOperatorAttr>(tblgen_reductionOperator)))) return emitError(loc, "'acc.reduction_combine' op attribute 'reductionOperator' failed to satisfy constraint: built-in reduction operations supported by OpenACC"); return ::mlir::success(); } ::llvm::LogicalResult ReductionCombineOp::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.reductionOperator; auto attr = dict.get("reductionOperator"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `reductionOperator` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ReductionCombineOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.reductionOperator; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("reductionOperator", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ReductionCombineOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.reductionOperator.getAsOpaquePointer())); } std::optional ReductionCombineOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "reductionOperator") return prop.reductionOperator; return std::nullopt; } void ReductionCombineOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "reductionOperator") { prop.reductionOperator = ::llvm::dyn_cast_or_null>(value); return; } } void ReductionCombineOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.reductionOperator) attrs.append("reductionOperator", prop.reductionOperator); } ::llvm::LogicalResult ReductionCombineOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReductionOperatorAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps20(attr, "reductionOperator", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ReductionCombineOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.reductionOperator))) return ::mlir::failure(); return ::mlir::success(); } void ReductionCombineOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.reductionOperator); } ::mlir::acc::ReductionOperator ReductionCombineOp::getReductionOperator() { auto attr = getReductionOperatorAttr(); return attr.getValue(); } void ReductionCombineOp::setReductionOperator(::mlir::acc::ReductionOperator attrValue) { getProperties().reductionOperator = ::mlir::acc::ReductionOperatorAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ReductionCombineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value destMemref, ::mlir::Value srcMemref, ::mlir::acc::ReductionOperatorAttr reductionOperator) { odsState.addOperands(destMemref); odsState.addOperands(srcMemref); odsState.getOrAddProperties().reductionOperator = reductionOperator; } ReductionCombineOp ReductionCombineOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value destMemref, ::mlir::Value srcMemref, ::mlir::acc::ReductionOperatorAttr reductionOperator) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(destMemref), std::forward(srcMemref), std::forward(reductionOperator)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionCombineOp ReductionCombineOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value destMemref, ::mlir::Value srcMemref, ::mlir::acc::ReductionOperatorAttr reductionOperator) { return create(builder, builder.getLoc(), std::forward(destMemref), std::forward(srcMemref), std::forward(reductionOperator)); } void ReductionCombineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value destMemref, ::mlir::Value srcMemref, ::mlir::acc::ReductionOperatorAttr reductionOperator) { odsState.addOperands(destMemref); odsState.addOperands(srcMemref); odsState.getOrAddProperties().reductionOperator = reductionOperator; assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReductionCombineOp ReductionCombineOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value destMemref, ::mlir::Value srcMemref, ::mlir::acc::ReductionOperatorAttr reductionOperator) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(destMemref), std::forward(srcMemref), std::forward(reductionOperator)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionCombineOp ReductionCombineOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value destMemref, ::mlir::Value srcMemref, ::mlir::acc::ReductionOperatorAttr reductionOperator) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(destMemref), std::forward(srcMemref), std::forward(reductionOperator)); } void ReductionCombineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value destMemref, ::mlir::Value srcMemref, ::mlir::acc::ReductionOperator reductionOperator) { odsState.addOperands(destMemref); odsState.addOperands(srcMemref); odsState.getOrAddProperties().reductionOperator = ::mlir::acc::ReductionOperatorAttr::get(odsBuilder.getContext(), reductionOperator); } ReductionCombineOp ReductionCombineOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value destMemref, ::mlir::Value srcMemref, ::mlir::acc::ReductionOperator reductionOperator) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(destMemref), std::forward(srcMemref), std::forward(reductionOperator)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionCombineOp ReductionCombineOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value destMemref, ::mlir::Value srcMemref, ::mlir::acc::ReductionOperator reductionOperator) { return create(builder, builder.getLoc(), std::forward(destMemref), std::forward(srcMemref), std::forward(reductionOperator)); } void ReductionCombineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value destMemref, ::mlir::Value srcMemref, ::mlir::acc::ReductionOperator reductionOperator) { odsState.addOperands(destMemref); odsState.addOperands(srcMemref); odsState.getOrAddProperties().reductionOperator = ::mlir::acc::ReductionOperatorAttr::get(odsBuilder.getContext(), reductionOperator); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReductionCombineOp ReductionCombineOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value destMemref, ::mlir::Value srcMemref, ::mlir::acc::ReductionOperator reductionOperator) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(destMemref), std::forward(srcMemref), std::forward(reductionOperator)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionCombineOp ReductionCombineOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value destMemref, ::mlir::Value srcMemref, ::mlir::acc::ReductionOperator reductionOperator) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(destMemref), std::forward(srcMemref), std::forward(reductionOperator)); } void ReductionCombineOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ReductionCombineOp ReductionCombineOp::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__; } ReductionCombineOp ReductionCombineOp::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 ReductionCombineOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ReductionCombineOp ReductionCombineOp::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__; } ReductionCombineOp ReductionCombineOp::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 ReductionCombineOp::verifyInvariantsImpl() { auto tblgen_reductionOperator = getProperties().reductionOperator; (void)tblgen_reductionOperator; if (!tblgen_reductionOperator) return emitOpError("requires attribute 'reductionOperator'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps20(*this, tblgen_reductionOperator, "reductionOperator"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ReductionCombineOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ReductionCombineOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcMemrefRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcMemrefOperands(&srcMemrefRawOperand, 1); ::llvm::SMLoc srcMemrefOperandsLoc; (void)srcMemrefOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand destMemrefRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> destMemrefOperands(&destMemrefRawOperand, 1); ::llvm::SMLoc destMemrefOperandsLoc; (void)destMemrefOperandsLoc; ::mlir::acc::ReductionOperatorAttr reductionOperatorAttr; ::mlir::Type destMemrefRawType{}; ::llvm::ArrayRef<::mlir::Type> destMemrefTypes(&destMemrefRawType, 1); srcMemrefOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcMemrefRawOperand)) return ::mlir::failure(); if (parser.parseKeyword("into")) return ::mlir::failure(); destMemrefOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(destMemrefRawOperand)) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(reductionOperatorAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (reductionOperatorAttr) result.getOrAddProperties().reductionOperator = reductionOperatorAttr; if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); destMemrefRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.resolveOperands(destMemrefOperands, destMemrefTypes, destMemrefOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(srcMemrefOperands, destMemrefTypes[0], srcMemrefOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ReductionCombineOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrcMemref(); _odsPrinter << ' ' << "into"; _odsPrinter << ' '; _odsPrinter << getDestMemref(); _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getReductionOperatorAttr()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getDestMemref().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("reductionOperator"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::ReductionCombineOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::ReductionCombineOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::ReductionCombineRegionOp definitions //===----------------------------------------------------------------------===// namespace detail { ReductionCombineRegionOpGenericAdaptorBase::ReductionCombineRegionOpGenericAdaptorBase(ReductionCombineRegionOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail ReductionCombineRegionOpAdaptor::ReductionCombineRegionOpAdaptor(ReductionCombineRegionOp op) : ReductionCombineRegionOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ReductionCombineRegionOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult ReductionCombineRegionOp::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 ReductionCombineRegionOp::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 ReductionCombineRegionOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional ReductionCombineRegionOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void ReductionCombineRegionOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void ReductionCombineRegionOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult ReductionCombineRegionOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void ReductionCombineRegionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value destVar, ::mlir::Value srcVar) { odsState.addOperands(destVar); odsState.addOperands(srcVar); (void)odsState.addRegion(); } ReductionCombineRegionOp ReductionCombineRegionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value destVar, ::mlir::Value srcVar) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(destVar), std::forward(srcVar)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionCombineRegionOp ReductionCombineRegionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value destVar, ::mlir::Value srcVar) { return create(builder, builder.getLoc(), std::forward(destVar), std::forward(srcVar)); } void ReductionCombineRegionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value destVar, ::mlir::Value srcVar) { odsState.addOperands(destVar); odsState.addOperands(srcVar); (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReductionCombineRegionOp ReductionCombineRegionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value destVar, ::mlir::Value srcVar) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(destVar), std::forward(srcVar)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionCombineRegionOp ReductionCombineRegionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value destVar, ::mlir::Value srcVar) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(destVar), std::forward(srcVar)); } void ReductionCombineRegionOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ReductionCombineRegionOp ReductionCombineRegionOp::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__; } ReductionCombineRegionOp ReductionCombineRegionOp::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 ReductionCombineRegionOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ReductionCombineRegionOp ReductionCombineRegionOp::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__; } ReductionCombineRegionOp ReductionCombineRegionOp::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 ReductionCombineRegionOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ReductionCombineRegionOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ReductionCombineRegionOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand srcVarRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcVarOperands(&srcVarRawOperand, 1); ::llvm::SMLoc srcVarOperandsLoc; (void)srcVarOperandsLoc; ::mlir::OpAsmParser::UnresolvedOperand destVarRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> destVarOperands(&destVarRawOperand, 1); ::llvm::SMLoc destVarOperandsLoc; (void)destVarOperandsLoc; ::mlir::Type srcVarRawType{}; ::llvm::ArrayRef<::mlir::Type> srcVarTypes(&srcVarRawType, 1); std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); srcVarOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(srcVarRawOperand)) return ::mlir::failure(); if (parser.parseKeyword("into")) return ::mlir::failure(); destVarOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(destVarRawOperand)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); srcVarRawType = type; } if (parser.parseRegion(*regionRegion)) return ::mlir::failure(); ensureTerminator(*regionRegion, parser.getBuilder(), result.location); { 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.addRegion(std::move(regionRegion)); if (parser.resolveOperands(destVarOperands, srcVarTypes[0], destVarOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(srcVarOperands, srcVarTypes, srcVarOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ReductionCombineRegionOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getSrcVar(); _odsPrinter << ' ' << "into"; _odsPrinter << ' '; _odsPrinter << getDestVar(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getSrcVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' '; { bool printTerminator = true; if (auto *term = getRegion().empty() ? nullptr : getRegion().begin()->getTerminator()) { printTerminator = !term->getAttrDictionary().empty() || term->getNumOperands() != 0 || term->getNumResults() != 0; } _odsPrinter.printRegion(getRegion(), /*printEntryBlockArgs=*/true, /*printBlockTerminators=*/printTerminator); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::ReductionCombineRegionOp) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::ReductionInitOp definitions //===----------------------------------------------------------------------===// namespace detail { ReductionInitOpGenericAdaptorBase::ReductionInitOpGenericAdaptorBase(ReductionInitOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::mlir::acc::ReductionOperator ReductionInitOpGenericAdaptorBase::getReductionOperator() { auto attr = getReductionOperatorAttr(); return attr.getValue(); } } // namespace detail ReductionInitOpAdaptor::ReductionInitOpAdaptor(ReductionInitOp op) : ReductionInitOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ReductionInitOpAdaptor::verify(::mlir::Location loc) { auto tblgen_reductionOperator = getProperties().reductionOperator; (void)tblgen_reductionOperator; if (!tblgen_reductionOperator) return emitError(loc, "'acc.reduction_init' op requires attribute 'reductionOperator'"); if (tblgen_reductionOperator && !((::llvm::isa<::mlir::acc::ReductionOperatorAttr>(tblgen_reductionOperator)))) return emitError(loc, "'acc.reduction_init' op attribute 'reductionOperator' failed to satisfy constraint: built-in reduction operations supported by OpenACC"); return ::mlir::success(); } ::llvm::LogicalResult ReductionInitOp::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.reductionOperator; auto attr = dict.get("reductionOperator"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `reductionOperator` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ReductionInitOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.reductionOperator; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("reductionOperator", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ReductionInitOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.reductionOperator.getAsOpaquePointer())); } std::optional ReductionInitOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "reductionOperator") return prop.reductionOperator; return std::nullopt; } void ReductionInitOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "reductionOperator") { prop.reductionOperator = ::llvm::dyn_cast_or_null>(value); return; } } void ReductionInitOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.reductionOperator) attrs.append("reductionOperator", prop.reductionOperator); } ::llvm::LogicalResult ReductionInitOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReductionOperatorAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps20(attr, "reductionOperator", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ReductionInitOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.reductionOperator))) return ::mlir::failure(); return ::mlir::success(); } void ReductionInitOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.reductionOperator); } ::mlir::acc::ReductionOperator ReductionInitOp::getReductionOperator() { auto attr = getReductionOperatorAttr(); return attr.getValue(); } void ReductionInitOp::setReductionOperator(::mlir::acc::ReductionOperator attrValue) { getProperties().reductionOperator = ::mlir::acc::ReductionOperatorAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ReductionInitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value var, ::mlir::acc::ReductionOperatorAttr reductionOperator) { odsState.addOperands(var); odsState.getOrAddProperties().reductionOperator = reductionOperator; (void)odsState.addRegion(); odsState.addTypes(result); } ReductionInitOp ReductionInitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value var, ::mlir::acc::ReductionOperatorAttr reductionOperator) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(var), std::forward(reductionOperator)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionInitOp ReductionInitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value var, ::mlir::acc::ReductionOperatorAttr reductionOperator) { return create(builder, builder.getLoc(), std::forward(result), std::forward(var), std::forward(reductionOperator)); } void ReductionInitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, ::mlir::acc::ReductionOperatorAttr reductionOperator) { odsState.addOperands(var); odsState.getOrAddProperties().reductionOperator = reductionOperator; (void)odsState.addRegion(); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ReductionInitOp::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); } ReductionInitOp ReductionInitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, ::mlir::acc::ReductionOperatorAttr reductionOperator) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(reductionOperator)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionInitOp ReductionInitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, ::mlir::acc::ReductionOperatorAttr reductionOperator) { return create(builder, builder.getLoc(), std::forward(var), std::forward(reductionOperator)); } void ReductionInitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::acc::ReductionOperatorAttr reductionOperator) { odsState.addOperands(var); odsState.getOrAddProperties().reductionOperator = reductionOperator; (void)odsState.addRegion(); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReductionInitOp ReductionInitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::acc::ReductionOperatorAttr reductionOperator) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(reductionOperator)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionInitOp ReductionInitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::acc::ReductionOperatorAttr reductionOperator) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(reductionOperator)); } void ReductionInitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value var, ::mlir::acc::ReductionOperator reductionOperator) { odsState.addOperands(var); odsState.getOrAddProperties().reductionOperator = ::mlir::acc::ReductionOperatorAttr::get(odsBuilder.getContext(), reductionOperator); (void)odsState.addRegion(); odsState.addTypes(result); } ReductionInitOp ReductionInitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value var, ::mlir::acc::ReductionOperator reductionOperator) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(var), std::forward(reductionOperator)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionInitOp ReductionInitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value var, ::mlir::acc::ReductionOperator reductionOperator) { return create(builder, builder.getLoc(), std::forward(result), std::forward(var), std::forward(reductionOperator)); } void ReductionInitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, ::mlir::acc::ReductionOperator reductionOperator) { odsState.addOperands(var); odsState.getOrAddProperties().reductionOperator = ::mlir::acc::ReductionOperatorAttr::get(odsBuilder.getContext(), reductionOperator); (void)odsState.addRegion(); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ReductionInitOp::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); } ReductionInitOp ReductionInitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, ::mlir::acc::ReductionOperator reductionOperator) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(reductionOperator)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionInitOp ReductionInitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, ::mlir::acc::ReductionOperator reductionOperator) { return create(builder, builder.getLoc(), std::forward(var), std::forward(reductionOperator)); } void ReductionInitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::acc::ReductionOperator reductionOperator) { odsState.addOperands(var); odsState.getOrAddProperties().reductionOperator = ::mlir::acc::ReductionOperatorAttr::get(odsBuilder.getContext(), reductionOperator); (void)odsState.addRegion(); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReductionInitOp ReductionInitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::acc::ReductionOperator reductionOperator) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(reductionOperator)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionInitOp ReductionInitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::acc::ReductionOperator reductionOperator) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(reductionOperator)); } void ReductionInitOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); 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."); } } ReductionInitOp ReductionInitOp::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__; } ReductionInitOp ReductionInitOp::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 ReductionInitOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); 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(ReductionInitOp::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)."); } } ReductionInitOp ReductionInitOp::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__; } ReductionInitOp ReductionInitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { return create(builder, builder.getLoc(), std::forward(operands), std::forward(attributes)); } void ReductionInitOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 1u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ReductionInitOp ReductionInitOp::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__; } ReductionInitOp ReductionInitOp::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 ReductionInitOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; if (::mlir::succeeded(ReductionInitOp::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)."); } } ReductionInitOp ReductionInitOp::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__; } ReductionInitOp ReductionInitOp::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 ReductionInitOp::verifyInvariantsImpl() { auto tblgen_reductionOperator = getProperties().reductionOperator; (void)tblgen_reductionOperator; if (!tblgen_reductionOperator) return emitOpError("requires attribute 'reductionOperator'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps20(*this, tblgen_reductionOperator, "reductionOperator"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ReductionInitOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::llvm::LogicalResult ReductionInitOp::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 ReductionInitOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::acc::ReductionOperatorAttr reductionOperatorAttr; ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); varOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(varRawOperand)) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(reductionOperatorAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (reductionOperatorAttr) result.getOrAddProperties().reductionOperator = reductionOperatorAttr; if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resultRawType = type; } if (parser.parseRegion(*regionRegion)) return ::mlir::failure(); ensureTerminator(*regionRegion, parser.getBuilder(), result.location); { 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.addRegion(std::move(regionRegion)); result.addTypes(resultTypes); if (parser.resolveOperands(varOperands, resultTypes[0], varOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ReductionInitOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getVar(); _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getReductionOperatorAttr()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; { auto type = getResult().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } _odsPrinter << ' '; { bool printTerminator = true; if (auto *term = getRegion().empty() ? nullptr : getRegion().begin()->getTerminator()) { printTerminator = !term->getAttrDictionary().empty() || term->getNumOperands() != 0 || term->getNumResults() != 0; } _odsPrinter.printRegion(getRegion(), /*printEntryBlockArgs=*/true, /*printBlockTerminators=*/printTerminator); } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("reductionOperator"); _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::ReductionInitOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::ReductionInitOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::ReductionOp definitions //===----------------------------------------------------------------------===// namespace detail { ReductionOpGenericAdaptorBase::ReductionOpGenericAdaptorBase(ReductionOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ReductionOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type ReductionOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > ReductionOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ReductionOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr ReductionOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause ReductionOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr ReductionOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool ReductionOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr ReductionOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool ReductionOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr ReductionOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier ReductionOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > ReductionOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > ReductionOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail ReductionOpAdaptor::ReductionOpAdaptor(ReductionOp op) : ReductionOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ReductionOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.reduction' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.reduction' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.reduction' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.reduction' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.reduction' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.reduction' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.reduction' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.reduction' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.reduction' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.reduction' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair ReductionOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange ReductionOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ReductionOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ReductionOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult ReductionOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute ReductionOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ReductionOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional ReductionOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void ReductionOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void ReductionOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult ReductionOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ReductionOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void ReductionOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type ReductionOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > ReductionOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > ReductionOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause ReductionOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool ReductionOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool ReductionOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier ReductionOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > ReductionOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > ReductionOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void ReductionOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void ReductionOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ReductionOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ReductionOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void ReductionOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ReductionOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void ReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } ReductionOp ReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionOp ReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void ReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } ReductionOp ReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionOp ReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void ReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } ReductionOp ReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionOp ReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void ReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } ReductionOp ReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionOp ReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void ReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } ReductionOp ReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionOp ReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void ReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReductionOp ReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionOp ReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void ReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } ReductionOp ReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionOp ReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void ReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReductionOp ReductionOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionOp ReductionOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void ReductionOp::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."); } } ReductionOp ReductionOp::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__; } ReductionOp ReductionOp::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 ReductionOp::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); } ReductionOp ReductionOp::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__; } ReductionOp ReductionOp::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 ReductionOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_reduction); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult ReductionOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ReductionOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ReductionOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void ReductionOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_reduction))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::ReductionOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::ReductionOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::ReductionRecipeOp definitions //===----------------------------------------------------------------------===// namespace detail { ReductionRecipeOpGenericAdaptorBase::ReductionRecipeOpGenericAdaptorBase(ReductionRecipeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::llvm::StringRef ReductionRecipeOpGenericAdaptorBase::getSymName() { auto attr = getSymNameAttr(); return attr.getValue(); } ::mlir::Type ReductionRecipeOpGenericAdaptorBase::getType() { auto attr = getTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::mlir::acc::ReductionOperator ReductionRecipeOpGenericAdaptorBase::getReductionOperator() { auto attr = getReductionOperatorAttr(); return attr.getValue(); } } // namespace detail ReductionRecipeOpAdaptor::ReductionRecipeOpAdaptor(ReductionRecipeOp op) : ReductionRecipeOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ReductionRecipeOpAdaptor::verify(::mlir::Location loc) { auto tblgen_reductionOperator = getProperties().reductionOperator; (void)tblgen_reductionOperator; if (!tblgen_reductionOperator) return emitError(loc, "'acc.reduction.recipe' op requires attribute 'reductionOperator'"); auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; if (!tblgen_sym_name) return emitError(loc, "'acc.reduction.recipe' op requires attribute 'sym_name'"); auto tblgen_type = getProperties().type; (void)tblgen_type; if (!tblgen_type) return emitError(loc, "'acc.reduction.recipe' op requires attribute 'type'"); if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name)))) return emitError(loc, "'acc.reduction.recipe' op attribute 'sym_name' failed to satisfy constraint: string attribute"); if (tblgen_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_type).getValue()))) && ((true)))) return emitError(loc, "'acc.reduction.recipe' op attribute 'type' failed to satisfy constraint: any type attribute"); if (tblgen_reductionOperator && !((::llvm::isa<::mlir::acc::ReductionOperatorAttr>(tblgen_reductionOperator)))) return emitError(loc, "'acc.reduction.recipe' op attribute 'reductionOperator' failed to satisfy constraint: built-in reduction operations supported by OpenACC"); return ::mlir::success(); } ::llvm::LogicalResult ReductionRecipeOp::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.reductionOperator; auto attr = dict.get("reductionOperator"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `reductionOperator` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sym_name; auto attr = dict.get("sym_name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sym_name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.type; auto attr = dict.get("type"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `type` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute ReductionRecipeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.reductionOperator; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("reductionOperator", propStorage)); } { const auto &propStorage = prop.sym_name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sym_name", propStorage)); } { const auto &propStorage = prop.type; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("type", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ReductionRecipeOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.reductionOperator.getAsOpaquePointer()), llvm::hash_value(prop.sym_name.getAsOpaquePointer()), llvm::hash_value(prop.type.getAsOpaquePointer())); } std::optional ReductionRecipeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "reductionOperator") return prop.reductionOperator; if (name == "sym_name") return prop.sym_name; if (name == "type") return prop.type; return std::nullopt; } void ReductionRecipeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "reductionOperator") { prop.reductionOperator = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sym_name") { prop.sym_name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "type") { prop.type = ::llvm::dyn_cast_or_null>(value); return; } } void ReductionRecipeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.reductionOperator) attrs.append("reductionOperator", prop.reductionOperator); if (prop.sym_name) attrs.append("sym_name", prop.sym_name); if (prop.type) attrs.append("type", prop.type); } ::llvm::LogicalResult ReductionRecipeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getReductionOperatorAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps20(attr, "reductionOperator", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "sym_name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "type", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ReductionRecipeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readAttribute(prop.reductionOperator))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.sym_name))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.type))) return ::mlir::failure(); return ::mlir::success(); } void ReductionRecipeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeAttribute(prop.reductionOperator); writer.writeAttribute(prop.sym_name); writer.writeAttribute(prop.type); } ::llvm::StringRef ReductionRecipeOp::getSymName() { auto attr = getSymNameAttr(); return attr.getValue(); } ::mlir::Type ReductionRecipeOp::getType() { auto attr = getTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::mlir::acc::ReductionOperator ReductionRecipeOp::getReductionOperator() { auto attr = getReductionOperatorAttr(); return attr.getValue(); } void ReductionRecipeOp::setSymName(::llvm::StringRef attrValue) { getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue); } void ReductionRecipeOp::setType(::mlir::Type attrValue) { getProperties().type = ::mlir::TypeAttr::get(attrValue); } void ReductionRecipeOp::setReductionOperator(::mlir::acc::ReductionOperator attrValue) { getProperties().reductionOperator = ::mlir::acc::ReductionOperatorAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void ReductionRecipeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, ::mlir::acc::ReductionOperatorAttr reductionOperator) { odsState.getOrAddProperties().sym_name = sym_name; odsState.getOrAddProperties().type = type; odsState.getOrAddProperties().reductionOperator = reductionOperator; (void)odsState.addRegion(); (void)odsState.addRegion(); (void)odsState.addRegion(); } ReductionRecipeOp ReductionRecipeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, ::mlir::acc::ReductionOperatorAttr reductionOperator) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sym_name), std::forward(type), std::forward(reductionOperator)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionRecipeOp ReductionRecipeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, ::mlir::acc::ReductionOperatorAttr reductionOperator) { return create(builder, builder.getLoc(), std::forward(sym_name), std::forward(type), std::forward(reductionOperator)); } void ReductionRecipeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, ::mlir::acc::ReductionOperatorAttr reductionOperator) { odsState.getOrAddProperties().sym_name = sym_name; odsState.getOrAddProperties().type = type; odsState.getOrAddProperties().reductionOperator = reductionOperator; (void)odsState.addRegion(); (void)odsState.addRegion(); (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReductionRecipeOp ReductionRecipeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, ::mlir::acc::ReductionOperatorAttr reductionOperator) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(sym_name), std::forward(type), std::forward(reductionOperator)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionRecipeOp ReductionRecipeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr type, ::mlir::acc::ReductionOperatorAttr reductionOperator) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(sym_name), std::forward(type), std::forward(reductionOperator)); } void ReductionRecipeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, ::mlir::Type type, ::mlir::acc::ReductionOperator reductionOperator) { odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); odsState.getOrAddProperties().type = ::mlir::TypeAttr::get(type); odsState.getOrAddProperties().reductionOperator = ::mlir::acc::ReductionOperatorAttr::get(odsBuilder.getContext(), reductionOperator); (void)odsState.addRegion(); (void)odsState.addRegion(); (void)odsState.addRegion(); } ReductionRecipeOp ReductionRecipeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef sym_name, ::mlir::Type type, ::mlir::acc::ReductionOperator reductionOperator) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sym_name), std::forward(type), std::forward(reductionOperator)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionRecipeOp ReductionRecipeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llvm::StringRef sym_name, ::mlir::Type type, ::mlir::acc::ReductionOperator reductionOperator) { return create(builder, builder.getLoc(), std::forward(sym_name), std::forward(type), std::forward(reductionOperator)); } void ReductionRecipeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type, ::mlir::acc::ReductionOperator reductionOperator) { odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); odsState.getOrAddProperties().type = ::mlir::TypeAttr::get(type); odsState.getOrAddProperties().reductionOperator = ::mlir::acc::ReductionOperatorAttr::get(odsBuilder.getContext(), reductionOperator); (void)odsState.addRegion(); (void)odsState.addRegion(); (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ReductionRecipeOp ReductionRecipeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type, ::mlir::acc::ReductionOperator reductionOperator) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(sym_name), std::forward(type), std::forward(reductionOperator)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ReductionRecipeOp ReductionRecipeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::Type type, ::mlir::acc::ReductionOperator reductionOperator) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(sym_name), std::forward(type), std::forward(reductionOperator)); } void ReductionRecipeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 3; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } ReductionRecipeOp ReductionRecipeOp::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__; } ReductionRecipeOp ReductionRecipeOp::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 ReductionRecipeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); for (unsigned i = 0; i != 3; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ReductionRecipeOp ReductionRecipeOp::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__; } ReductionRecipeOp ReductionRecipeOp::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 ReductionRecipeOp::verifyInvariantsImpl() { auto tblgen_reductionOperator = getProperties().reductionOperator; (void)tblgen_reductionOperator; if (!tblgen_reductionOperator) return emitOpError("requires attribute 'reductionOperator'"); auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'"); auto tblgen_type = getProperties().type; (void)tblgen_type; if (!tblgen_type) return emitOpError("requires attribute 'type'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_sym_name, "sym_name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_type, "type"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps20(*this, tblgen_reductionOperator, "reductionOperator"))) return ::mlir::failure(); { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "initRegion", index++))) return ::mlir::failure(); for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "combinerRegion", index++))) return ::mlir::failure(); for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(2))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "destroyRegion", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ReductionRecipeOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult ReductionRecipeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::StringAttr sym_nameAttr; ::mlir::TypeAttr typeAttr; ::mlir::acc::ReductionOperatorAttr reductionOperatorAttr; std::unique_ptr<::mlir::Region> initRegionRegion = std::make_unique<::mlir::Region>(); std::unique_ptr<::mlir::Region> combinerRegionRegion = std::make_unique<::mlir::Region>(); std::unique_ptr<::mlir::Region> destroyRegionRegion = std::make_unique<::mlir::Region>(); if (parser.parseSymbolName(sym_nameAttr)) return ::mlir::failure(); if (sym_nameAttr) result.getOrAddProperties().sym_name = sym_nameAttr; if (parser.parseColon()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(typeAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (typeAttr) result.getOrAddProperties().type = typeAttr; { 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.parseKeyword("reduction_operator")) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(reductionOperatorAttr, ::mlir::Type{})) { return ::mlir::failure(); } if (reductionOperatorAttr) result.getOrAddProperties().reductionOperator = reductionOperatorAttr; if (parser.parseKeyword("init")) return ::mlir::failure(); if (parser.parseRegion(*initRegionRegion)) return ::mlir::failure(); if (parser.parseKeyword("combiner")) return ::mlir::failure(); if (parser.parseRegion(*combinerRegionRegion)) return ::mlir::failure(); if (::mlir::succeeded(parser.parseOptionalKeyword("destroy"))) { if (parser.parseRegion(*destroyRegionRegion)) return ::mlir::failure(); } result.addRegion(std::move(initRegionRegion)); result.addRegion(std::move(combinerRegionRegion)); result.addRegion(std::move(destroyRegionRegion)); return ::mlir::success(); } void ReductionRecipeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printSymbolName(getSymNameAttr().getValue()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter.printAttributeWithoutType(getTypeAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("sym_name"); elidedAttrs.push_back("type"); elidedAttrs.push_back("reductionOperator"); _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << "reduction_operator"; _odsPrinter << ' '; _odsPrinter.printStrippedAttrOrType(getReductionOperatorAttr()); _odsPrinter << ' ' << "init"; _odsPrinter << ' '; _odsPrinter.printRegion(getInitRegion()); _odsPrinter << ' ' << "combiner"; _odsPrinter << ' '; _odsPrinter.printRegion(getCombinerRegion()); if (!getDestroyRegion().empty()) { _odsPrinter << ' ' << "destroy"; _odsPrinter << ' '; _odsPrinter.printRegion(getDestroyRegion()); } } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::ReductionRecipeOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::ReductionRecipeOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::RoutineOp definitions //===----------------------------------------------------------------------===// namespace detail { RoutineOpGenericAdaptorBase::RoutineOpGenericAdaptorBase(RoutineOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} ::llvm::StringRef RoutineOpGenericAdaptorBase::getSymName() { auto attr = getSymNameAttr(); return attr.getValue(); } ::mlir::SymbolRefAttr RoutineOpGenericAdaptorBase::getFuncName() { auto attr = getFuncNameAttr(); return attr; } ::std::optional< ::mlir::ArrayAttr > RoutineOpGenericAdaptorBase::getBindIdName() { auto attr = getBindIdNameAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOpGenericAdaptorBase::getBindStrName() { auto attr = getBindStrNameAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOpGenericAdaptorBase::getBindIdNameDeviceType() { auto attr = getBindIdNameDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOpGenericAdaptorBase::getBindStrNameDeviceType() { auto attr = getBindStrNameDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOpGenericAdaptorBase::getWorker() { auto attr = getWorkerAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOpGenericAdaptorBase::getVector() { auto attr = getVectorAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOpGenericAdaptorBase::getSeq() { auto attr = getSeqAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::UnitAttr RoutineOpGenericAdaptorBase::getNohostAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nohost); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool RoutineOpGenericAdaptorBase::getNohost() { auto attr = getNohostAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::mlir::UnitAttr RoutineOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().implicit); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool RoutineOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::std::optional< ::mlir::ArrayAttr > RoutineOpGenericAdaptorBase::getGang() { auto attr = getGangAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOpGenericAdaptorBase::getGangDim() { auto attr = getGangDimAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOpGenericAdaptorBase::getGangDimDeviceType() { auto attr = getGangDimDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } } // namespace detail RoutineOpAdaptor::RoutineOpAdaptor(RoutineOp op) : RoutineOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult RoutineOpAdaptor::verify(::mlir::Location loc) { auto tblgen_bindIdName = getProperties().bindIdName; (void)tblgen_bindIdName; auto tblgen_bindIdNameDeviceType = getProperties().bindIdNameDeviceType; (void)tblgen_bindIdNameDeviceType; auto tblgen_bindStrName = getProperties().bindStrName; (void)tblgen_bindStrName; auto tblgen_bindStrNameDeviceType = getProperties().bindStrNameDeviceType; (void)tblgen_bindStrNameDeviceType; auto tblgen_func_name = getProperties().func_name; (void)tblgen_func_name; if (!tblgen_func_name) return emitError(loc, "'acc.routine' op requires attribute 'func_name'"); auto tblgen_gang = getProperties().gang; (void)tblgen_gang; auto tblgen_gangDim = getProperties().gangDim; (void)tblgen_gangDim; auto tblgen_gangDimDeviceType = getProperties().gangDimDeviceType; (void)tblgen_gangDimDeviceType; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_nohost = getProperties().nohost; (void)tblgen_nohost; auto tblgen_seq = getProperties().seq; (void)tblgen_seq; auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; if (!tblgen_sym_name) return emitError(loc, "'acc.routine' op requires attribute 'sym_name'"); auto tblgen_vector = getProperties().vector; (void)tblgen_vector; auto tblgen_worker = getProperties().worker; (void)tblgen_worker; if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name)))) return emitError(loc, "'acc.routine' op attribute 'sym_name' failed to satisfy constraint: string attribute"); if (tblgen_func_name && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_func_name)))) return emitError(loc, "'acc.routine' op attribute 'func_name' failed to satisfy constraint: symbol reference attribute"); if (tblgen_bindIdName && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_bindIdName))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_bindIdName), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); })))) return emitError(loc, "'acc.routine' op attribute 'bindIdName' failed to satisfy constraint: symbol ref array attribute"); if (tblgen_bindStrName && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_bindStrName))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_bindStrName), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::StringAttr>(attr))); })))) return emitError(loc, "'acc.routine' op attribute 'bindStrName' failed to satisfy constraint: string array attribute"); if (tblgen_bindIdNameDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_bindIdNameDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_bindIdNameDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.routine' op attribute 'bindIdNameDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_bindStrNameDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_bindStrNameDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_bindStrNameDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.routine' op attribute 'bindStrNameDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_worker && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_worker))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_worker), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.routine' op attribute 'worker' failed to satisfy constraint: device type array attribute"); if (tblgen_vector && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_vector))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_vector), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.routine' op attribute 'vector' failed to satisfy constraint: device type array attribute"); if (tblgen_seq && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_seq))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_seq), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.routine' op attribute 'seq' failed to satisfy constraint: device type array attribute"); if (tblgen_nohost && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nohost)))) return emitError(loc, "'acc.routine' op attribute 'nohost' failed to satisfy constraint: unit attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::UnitAttr>(tblgen_implicit)))) return emitError(loc, "'acc.routine' op attribute 'implicit' failed to satisfy constraint: unit attribute"); if (tblgen_gang && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_gang))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_gang), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.routine' op attribute 'gang' failed to satisfy constraint: device type array attribute"); if (tblgen_gangDim && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_gangDim))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_gangDim), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); })))) return emitError(loc, "'acc.routine' op attribute 'gangDim' failed to satisfy constraint: 64-bit integer array attribute"); if (tblgen_gangDimDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_gangDimDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_gangDimDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.routine' op attribute 'gangDimDeviceType' failed to satisfy constraint: device type array attribute"); return ::mlir::success(); } ::llvm::LogicalResult RoutineOp::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.bindIdName; auto attr = dict.get("bindIdName"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `bindIdName` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.bindIdNameDeviceType; auto attr = dict.get("bindIdNameDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `bindIdNameDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.bindStrName; auto attr = dict.get("bindStrName"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `bindStrName` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.bindStrNameDeviceType; auto attr = dict.get("bindStrNameDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `bindStrNameDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.func_name; auto attr = dict.get("func_name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `func_name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.gang; auto attr = dict.get("gang"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `gang` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.gangDim; auto attr = dict.get("gangDim"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `gangDim` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.gangDimDeviceType; auto attr = dict.get("gangDimDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `gangDimDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.nohost; auto attr = dict.get("nohost"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `nohost` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.seq; auto attr = dict.get("seq"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `seq` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.sym_name; auto attr = dict.get("sym_name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `sym_name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.vector; auto attr = dict.get("vector"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `vector` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.worker; auto attr = dict.get("worker"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `worker` in property conversion: " << attr; return ::mlir::failure(); } } } return ::mlir::success(); } ::mlir::Attribute RoutineOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.bindIdName; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("bindIdName", propStorage)); } { const auto &propStorage = prop.bindIdNameDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("bindIdNameDeviceType", propStorage)); } { const auto &propStorage = prop.bindStrName; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("bindStrName", propStorage)); } { const auto &propStorage = prop.bindStrNameDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("bindStrNameDeviceType", propStorage)); } { const auto &propStorage = prop.func_name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("func_name", propStorage)); } { const auto &propStorage = prop.gang; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("gang", propStorage)); } { const auto &propStorage = prop.gangDim; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("gangDim", propStorage)); } { const auto &propStorage = prop.gangDimDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("gangDimDeviceType", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.nohost; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("nohost", propStorage)); } { const auto &propStorage = prop.seq; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("seq", propStorage)); } { const auto &propStorage = prop.sym_name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("sym_name", propStorage)); } { const auto &propStorage = prop.vector; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("vector", propStorage)); } { const auto &propStorage = prop.worker; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("worker", propStorage)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code RoutineOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.bindIdName.getAsOpaquePointer()), llvm::hash_value(prop.bindIdNameDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.bindStrName.getAsOpaquePointer()), llvm::hash_value(prop.bindStrNameDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.func_name.getAsOpaquePointer()), llvm::hash_value(prop.gang.getAsOpaquePointer()), llvm::hash_value(prop.gangDim.getAsOpaquePointer()), llvm::hash_value(prop.gangDimDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.nohost.getAsOpaquePointer()), llvm::hash_value(prop.seq.getAsOpaquePointer()), llvm::hash_value(prop.sym_name.getAsOpaquePointer()), llvm::hash_value(prop.vector.getAsOpaquePointer()), llvm::hash_value(prop.worker.getAsOpaquePointer())); } std::optional RoutineOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "bindIdName") return prop.bindIdName; if (name == "bindIdNameDeviceType") return prop.bindIdNameDeviceType; if (name == "bindStrName") return prop.bindStrName; if (name == "bindStrNameDeviceType") return prop.bindStrNameDeviceType; if (name == "func_name") return prop.func_name; if (name == "gang") return prop.gang; if (name == "gangDim") return prop.gangDim; if (name == "gangDimDeviceType") return prop.gangDimDeviceType; if (name == "implicit") return prop.implicit; if (name == "nohost") return prop.nohost; if (name == "seq") return prop.seq; if (name == "sym_name") return prop.sym_name; if (name == "vector") return prop.vector; if (name == "worker") return prop.worker; return std::nullopt; } void RoutineOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "bindIdName") { prop.bindIdName = ::llvm::dyn_cast_or_null>(value); return; } if (name == "bindIdNameDeviceType") { prop.bindIdNameDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "bindStrName") { prop.bindStrName = ::llvm::dyn_cast_or_null>(value); return; } if (name == "bindStrNameDeviceType") { prop.bindStrNameDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "func_name") { prop.func_name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "gang") { prop.gang = ::llvm::dyn_cast_or_null>(value); return; } if (name == "gangDim") { prop.gangDim = ::llvm::dyn_cast_or_null>(value); return; } if (name == "gangDimDeviceType") { prop.gangDimDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "nohost") { prop.nohost = ::llvm::dyn_cast_or_null>(value); return; } if (name == "seq") { prop.seq = ::llvm::dyn_cast_or_null>(value); return; } if (name == "sym_name") { prop.sym_name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "vector") { prop.vector = ::llvm::dyn_cast_or_null>(value); return; } if (name == "worker") { prop.worker = ::llvm::dyn_cast_or_null>(value); return; } } void RoutineOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.bindIdName) attrs.append("bindIdName", prop.bindIdName); if (prop.bindIdNameDeviceType) attrs.append("bindIdNameDeviceType", prop.bindIdNameDeviceType); if (prop.bindStrName) attrs.append("bindStrName", prop.bindStrName); if (prop.bindStrNameDeviceType) attrs.append("bindStrNameDeviceType", prop.bindStrNameDeviceType); if (prop.func_name) attrs.append("func_name", prop.func_name); if (prop.gang) attrs.append("gang", prop.gang); if (prop.gangDim) attrs.append("gangDim", prop.gangDim); if (prop.gangDimDeviceType) attrs.append("gangDimDeviceType", prop.gangDimDeviceType); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.nohost) attrs.append("nohost", prop.nohost); if (prop.seq) attrs.append("seq", prop.seq); if (prop.sym_name) attrs.append("sym_name", prop.sym_name); if (prop.vector) attrs.append("vector", prop.vector); if (prop.worker) attrs.append("worker", prop.worker); } ::llvm::LogicalResult RoutineOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getBindIdNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps21(attr, "bindIdName", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getBindIdNameDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "bindIdNameDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getBindStrNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps22(attr, "bindStrName", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getBindStrNameDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "bindStrNameDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getFuncNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "func_name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getGangAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "gang", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getGangDimAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps15(attr, "gangDim", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getGangDimDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "gangDimDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNohostAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "nohost", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSeqAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "seq", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "sym_name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVectorAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "vector", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWorkerAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "worker", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult RoutineOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.bindIdName))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.bindIdNameDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.bindStrName))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.bindStrNameDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.func_name))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.gang))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.gangDim))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.gangDimDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.nohost))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.seq))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.sym_name))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.vector))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.worker))) return ::mlir::failure(); return ::mlir::success(); } void RoutineOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.bindIdName); writer.writeOptionalAttribute(prop.bindIdNameDeviceType); writer.writeOptionalAttribute(prop.bindStrName); writer.writeOptionalAttribute(prop.bindStrNameDeviceType); writer.writeAttribute(prop.func_name); writer.writeOptionalAttribute(prop.gang); writer.writeOptionalAttribute(prop.gangDim); writer.writeOptionalAttribute(prop.gangDimDeviceType); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.nohost); writer.writeOptionalAttribute(prop.seq); writer.writeAttribute(prop.sym_name); writer.writeOptionalAttribute(prop.vector); writer.writeOptionalAttribute(prop.worker); } ::llvm::StringRef RoutineOp::getSymName() { auto attr = getSymNameAttr(); return attr.getValue(); } ::mlir::SymbolRefAttr RoutineOp::getFuncName() { auto attr = getFuncNameAttr(); return attr; } ::std::optional< ::mlir::ArrayAttr > RoutineOp::getBindIdName() { auto attr = getBindIdNameAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOp::getBindStrName() { auto attr = getBindStrNameAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOp::getBindIdNameDeviceType() { auto attr = getBindIdNameDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOp::getBindStrNameDeviceType() { auto attr = getBindStrNameDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOp::getWorker() { auto attr = getWorkerAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOp::getVector() { auto attr = getVectorAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOp::getSeq() { auto attr = getSeqAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } bool RoutineOp::getNohost() { auto attr = getNohostAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } bool RoutineOp::getImplicit() { auto attr = getImplicitAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::std::optional< ::mlir::ArrayAttr > RoutineOp::getGang() { auto attr = getGangAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOp::getGangDim() { auto attr = getGangDimAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > RoutineOp::getGangDimDeviceType() { auto attr = getGangDimDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } void RoutineOp::setSymName(::llvm::StringRef attrValue) { getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue); } void RoutineOp::setNohost(bool attrValue) { auto &odsProp = getProperties().nohost; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void RoutineOp::setImplicit(bool attrValue) { auto &odsProp = getProperties().implicit; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void RoutineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::SymbolRefAttr func_name, /*optional*/::mlir::ArrayAttr bindIdName, /*optional*/::mlir::ArrayAttr bindStrName, /*optional*/::mlir::ArrayAttr bindIdNameDeviceType, /*optional*/::mlir::ArrayAttr bindStrNameDeviceType, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, /*optional*/::mlir::ArrayAttr seq, /*optional*/::mlir::UnitAttr nohost, /*optional*/::mlir::UnitAttr implicit, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr gangDim, /*optional*/::mlir::ArrayAttr gangDimDeviceType) { odsState.getOrAddProperties().sym_name = sym_name; odsState.getOrAddProperties().func_name = func_name; if (bindIdName) { odsState.getOrAddProperties().bindIdName = bindIdName; } if (bindStrName) { odsState.getOrAddProperties().bindStrName = bindStrName; } if (bindIdNameDeviceType) { odsState.getOrAddProperties().bindIdNameDeviceType = bindIdNameDeviceType; } if (bindStrNameDeviceType) { odsState.getOrAddProperties().bindStrNameDeviceType = bindStrNameDeviceType; } if (worker) { odsState.getOrAddProperties().worker = worker; } if (vector) { odsState.getOrAddProperties().vector = vector; } if (seq) { odsState.getOrAddProperties().seq = seq; } if (nohost) { odsState.getOrAddProperties().nohost = nohost; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (gang) { odsState.getOrAddProperties().gang = gang; } if (gangDim) { odsState.getOrAddProperties().gangDim = gangDim; } if (gangDimDeviceType) { odsState.getOrAddProperties().gangDimDeviceType = gangDimDeviceType; } } RoutineOp RoutineOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::StringAttr sym_name, ::mlir::SymbolRefAttr func_name, /*optional*/::mlir::ArrayAttr bindIdName, /*optional*/::mlir::ArrayAttr bindStrName, /*optional*/::mlir::ArrayAttr bindIdNameDeviceType, /*optional*/::mlir::ArrayAttr bindStrNameDeviceType, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, /*optional*/::mlir::ArrayAttr seq, /*optional*/::mlir::UnitAttr nohost, /*optional*/::mlir::UnitAttr implicit, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr gangDim, /*optional*/::mlir::ArrayAttr gangDimDeviceType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sym_name), std::forward(func_name), std::forward(bindIdName), std::forward(bindStrName), std::forward(bindIdNameDeviceType), std::forward(bindStrNameDeviceType), std::forward(worker), std::forward(vector), std::forward(seq), std::forward(nohost), std::forward(implicit), std::forward(gang), std::forward(gangDim), std::forward(gangDimDeviceType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RoutineOp RoutineOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::StringAttr sym_name, ::mlir::SymbolRefAttr func_name, /*optional*/::mlir::ArrayAttr bindIdName, /*optional*/::mlir::ArrayAttr bindStrName, /*optional*/::mlir::ArrayAttr bindIdNameDeviceType, /*optional*/::mlir::ArrayAttr bindStrNameDeviceType, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, /*optional*/::mlir::ArrayAttr seq, /*optional*/::mlir::UnitAttr nohost, /*optional*/::mlir::UnitAttr implicit, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr gangDim, /*optional*/::mlir::ArrayAttr gangDimDeviceType) { return create(builder, builder.getLoc(), std::forward(sym_name), std::forward(func_name), std::forward(bindIdName), std::forward(bindStrName), std::forward(bindIdNameDeviceType), std::forward(bindStrNameDeviceType), std::forward(worker), std::forward(vector), std::forward(seq), std::forward(nohost), std::forward(implicit), std::forward(gang), std::forward(gangDim), std::forward(gangDimDeviceType)); } void RoutineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::SymbolRefAttr func_name, /*optional*/::mlir::ArrayAttr bindIdName, /*optional*/::mlir::ArrayAttr bindStrName, /*optional*/::mlir::ArrayAttr bindIdNameDeviceType, /*optional*/::mlir::ArrayAttr bindStrNameDeviceType, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, /*optional*/::mlir::ArrayAttr seq, /*optional*/::mlir::UnitAttr nohost, /*optional*/::mlir::UnitAttr implicit, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr gangDim, /*optional*/::mlir::ArrayAttr gangDimDeviceType) { odsState.getOrAddProperties().sym_name = sym_name; odsState.getOrAddProperties().func_name = func_name; if (bindIdName) { odsState.getOrAddProperties().bindIdName = bindIdName; } if (bindStrName) { odsState.getOrAddProperties().bindStrName = bindStrName; } if (bindIdNameDeviceType) { odsState.getOrAddProperties().bindIdNameDeviceType = bindIdNameDeviceType; } if (bindStrNameDeviceType) { odsState.getOrAddProperties().bindStrNameDeviceType = bindStrNameDeviceType; } if (worker) { odsState.getOrAddProperties().worker = worker; } if (vector) { odsState.getOrAddProperties().vector = vector; } if (seq) { odsState.getOrAddProperties().seq = seq; } if (nohost) { odsState.getOrAddProperties().nohost = nohost; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (gang) { odsState.getOrAddProperties().gang = gang; } if (gangDim) { odsState.getOrAddProperties().gangDim = gangDim; } if (gangDimDeviceType) { odsState.getOrAddProperties().gangDimDeviceType = gangDimDeviceType; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } RoutineOp RoutineOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::SymbolRefAttr func_name, /*optional*/::mlir::ArrayAttr bindIdName, /*optional*/::mlir::ArrayAttr bindStrName, /*optional*/::mlir::ArrayAttr bindIdNameDeviceType, /*optional*/::mlir::ArrayAttr bindStrNameDeviceType, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, /*optional*/::mlir::ArrayAttr seq, /*optional*/::mlir::UnitAttr nohost, /*optional*/::mlir::UnitAttr implicit, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr gangDim, /*optional*/::mlir::ArrayAttr gangDimDeviceType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(sym_name), std::forward(func_name), std::forward(bindIdName), std::forward(bindStrName), std::forward(bindIdNameDeviceType), std::forward(bindStrNameDeviceType), std::forward(worker), std::forward(vector), std::forward(seq), std::forward(nohost), std::forward(implicit), std::forward(gang), std::forward(gangDim), std::forward(gangDimDeviceType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RoutineOp RoutineOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::SymbolRefAttr func_name, /*optional*/::mlir::ArrayAttr bindIdName, /*optional*/::mlir::ArrayAttr bindStrName, /*optional*/::mlir::ArrayAttr bindIdNameDeviceType, /*optional*/::mlir::ArrayAttr bindStrNameDeviceType, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, /*optional*/::mlir::ArrayAttr seq, /*optional*/::mlir::UnitAttr nohost, /*optional*/::mlir::UnitAttr implicit, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr gangDim, /*optional*/::mlir::ArrayAttr gangDimDeviceType) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(sym_name), std::forward(func_name), std::forward(bindIdName), std::forward(bindStrName), std::forward(bindIdNameDeviceType), std::forward(bindStrNameDeviceType), std::forward(worker), std::forward(vector), std::forward(seq), std::forward(nohost), std::forward(implicit), std::forward(gang), std::forward(gangDim), std::forward(gangDimDeviceType)); } void RoutineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, ::mlir::SymbolRefAttr func_name, /*optional*/::mlir::ArrayAttr bindIdName, /*optional*/::mlir::ArrayAttr bindStrName, /*optional*/::mlir::ArrayAttr bindIdNameDeviceType, /*optional*/::mlir::ArrayAttr bindStrNameDeviceType, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, /*optional*/::mlir::ArrayAttr seq, /*optional*/bool nohost, /*optional*/bool implicit, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr gangDim, /*optional*/::mlir::ArrayAttr gangDimDeviceType) { odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); odsState.getOrAddProperties().func_name = func_name; if (bindIdName) { odsState.getOrAddProperties().bindIdName = bindIdName; } if (bindStrName) { odsState.getOrAddProperties().bindStrName = bindStrName; } if (bindIdNameDeviceType) { odsState.getOrAddProperties().bindIdNameDeviceType = bindIdNameDeviceType; } if (bindStrNameDeviceType) { odsState.getOrAddProperties().bindStrNameDeviceType = bindStrNameDeviceType; } if (worker) { odsState.getOrAddProperties().worker = worker; } if (vector) { odsState.getOrAddProperties().vector = vector; } if (seq) { odsState.getOrAddProperties().seq = seq; } if (nohost) { odsState.getOrAddProperties().nohost = ((nohost) ? odsBuilder.getUnitAttr() : nullptr); } if (implicit) { odsState.getOrAddProperties().implicit = ((implicit) ? odsBuilder.getUnitAttr() : nullptr); } if (gang) { odsState.getOrAddProperties().gang = gang; } if (gangDim) { odsState.getOrAddProperties().gangDim = gangDim; } if (gangDimDeviceType) { odsState.getOrAddProperties().gangDimDeviceType = gangDimDeviceType; } } RoutineOp RoutineOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef sym_name, ::mlir::SymbolRefAttr func_name, /*optional*/::mlir::ArrayAttr bindIdName, /*optional*/::mlir::ArrayAttr bindStrName, /*optional*/::mlir::ArrayAttr bindIdNameDeviceType, /*optional*/::mlir::ArrayAttr bindStrNameDeviceType, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, /*optional*/::mlir::ArrayAttr seq, /*optional*/bool nohost, /*optional*/bool implicit, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr gangDim, /*optional*/::mlir::ArrayAttr gangDimDeviceType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(sym_name), std::forward(func_name), std::forward(bindIdName), std::forward(bindStrName), std::forward(bindIdNameDeviceType), std::forward(bindStrNameDeviceType), std::forward(worker), std::forward(vector), std::forward(seq), std::forward(nohost), std::forward(implicit), std::forward(gang), std::forward(gangDim), std::forward(gangDimDeviceType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RoutineOp RoutineOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llvm::StringRef sym_name, ::mlir::SymbolRefAttr func_name, /*optional*/::mlir::ArrayAttr bindIdName, /*optional*/::mlir::ArrayAttr bindStrName, /*optional*/::mlir::ArrayAttr bindIdNameDeviceType, /*optional*/::mlir::ArrayAttr bindStrNameDeviceType, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, /*optional*/::mlir::ArrayAttr seq, /*optional*/bool nohost, /*optional*/bool implicit, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr gangDim, /*optional*/::mlir::ArrayAttr gangDimDeviceType) { return create(builder, builder.getLoc(), std::forward(sym_name), std::forward(func_name), std::forward(bindIdName), std::forward(bindStrName), std::forward(bindIdNameDeviceType), std::forward(bindStrNameDeviceType), std::forward(worker), std::forward(vector), std::forward(seq), std::forward(nohost), std::forward(implicit), std::forward(gang), std::forward(gangDim), std::forward(gangDimDeviceType)); } void RoutineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::SymbolRefAttr func_name, /*optional*/::mlir::ArrayAttr bindIdName, /*optional*/::mlir::ArrayAttr bindStrName, /*optional*/::mlir::ArrayAttr bindIdNameDeviceType, /*optional*/::mlir::ArrayAttr bindStrNameDeviceType, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, /*optional*/::mlir::ArrayAttr seq, /*optional*/bool nohost, /*optional*/bool implicit, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr gangDim, /*optional*/::mlir::ArrayAttr gangDimDeviceType) { odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); odsState.getOrAddProperties().func_name = func_name; if (bindIdName) { odsState.getOrAddProperties().bindIdName = bindIdName; } if (bindStrName) { odsState.getOrAddProperties().bindStrName = bindStrName; } if (bindIdNameDeviceType) { odsState.getOrAddProperties().bindIdNameDeviceType = bindIdNameDeviceType; } if (bindStrNameDeviceType) { odsState.getOrAddProperties().bindStrNameDeviceType = bindStrNameDeviceType; } if (worker) { odsState.getOrAddProperties().worker = worker; } if (vector) { odsState.getOrAddProperties().vector = vector; } if (seq) { odsState.getOrAddProperties().seq = seq; } if (nohost) { odsState.getOrAddProperties().nohost = ((nohost) ? odsBuilder.getUnitAttr() : nullptr); } if (implicit) { odsState.getOrAddProperties().implicit = ((implicit) ? odsBuilder.getUnitAttr() : nullptr); } if (gang) { odsState.getOrAddProperties().gang = gang; } if (gangDim) { odsState.getOrAddProperties().gangDim = gangDim; } if (gangDimDeviceType) { odsState.getOrAddProperties().gangDimDeviceType = gangDimDeviceType; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } RoutineOp RoutineOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::SymbolRefAttr func_name, /*optional*/::mlir::ArrayAttr bindIdName, /*optional*/::mlir::ArrayAttr bindStrName, /*optional*/::mlir::ArrayAttr bindIdNameDeviceType, /*optional*/::mlir::ArrayAttr bindStrNameDeviceType, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, /*optional*/::mlir::ArrayAttr seq, /*optional*/bool nohost, /*optional*/bool implicit, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr gangDim, /*optional*/::mlir::ArrayAttr gangDimDeviceType) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(sym_name), std::forward(func_name), std::forward(bindIdName), std::forward(bindStrName), std::forward(bindIdNameDeviceType), std::forward(bindStrNameDeviceType), std::forward(worker), std::forward(vector), std::forward(seq), std::forward(nohost), std::forward(implicit), std::forward(gang), std::forward(gangDim), std::forward(gangDimDeviceType)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } RoutineOp RoutineOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::SymbolRefAttr func_name, /*optional*/::mlir::ArrayAttr bindIdName, /*optional*/::mlir::ArrayAttr bindStrName, /*optional*/::mlir::ArrayAttr bindIdNameDeviceType, /*optional*/::mlir::ArrayAttr bindStrNameDeviceType, /*optional*/::mlir::ArrayAttr worker, /*optional*/::mlir::ArrayAttr vector, /*optional*/::mlir::ArrayAttr seq, /*optional*/bool nohost, /*optional*/bool implicit, /*optional*/::mlir::ArrayAttr gang, /*optional*/::mlir::ArrayAttr gangDim, /*optional*/::mlir::ArrayAttr gangDimDeviceType) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(sym_name), std::forward(func_name), std::forward(bindIdName), std::forward(bindStrName), std::forward(bindIdNameDeviceType), std::forward(bindStrNameDeviceType), std::forward(worker), std::forward(vector), std::forward(seq), std::forward(nohost), std::forward(implicit), std::forward(gang), std::forward(gangDim), std::forward(gangDimDeviceType)); } void RoutineOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } RoutineOp RoutineOp::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__; } RoutineOp RoutineOp::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 RoutineOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } RoutineOp RoutineOp::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__; } RoutineOp RoutineOp::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 RoutineOp::verifyInvariantsImpl() { auto tblgen_bindIdName = getProperties().bindIdName; (void)tblgen_bindIdName; auto tblgen_bindIdNameDeviceType = getProperties().bindIdNameDeviceType; (void)tblgen_bindIdNameDeviceType; auto tblgen_bindStrName = getProperties().bindStrName; (void)tblgen_bindStrName; auto tblgen_bindStrNameDeviceType = getProperties().bindStrNameDeviceType; (void)tblgen_bindStrNameDeviceType; auto tblgen_func_name = getProperties().func_name; (void)tblgen_func_name; if (!tblgen_func_name) return emitOpError("requires attribute 'func_name'"); auto tblgen_gang = getProperties().gang; (void)tblgen_gang; auto tblgen_gangDim = getProperties().gangDim; (void)tblgen_gangDim; auto tblgen_gangDimDeviceType = getProperties().gangDimDeviceType; (void)tblgen_gangDimDeviceType; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_nohost = getProperties().nohost; (void)tblgen_nohost; auto tblgen_seq = getProperties().seq; (void)tblgen_seq; auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'"); auto tblgen_vector = getProperties().vector; (void)tblgen_vector; auto tblgen_worker = getProperties().worker; (void)tblgen_worker; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_sym_name, "sym_name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_func_name, "func_name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps21(*this, tblgen_bindIdName, "bindIdName"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps22(*this, tblgen_bindStrName, "bindStrName"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_bindIdNameDeviceType, "bindIdNameDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_bindStrNameDeviceType, "bindStrNameDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_worker, "worker"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_vector, "vector"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_seq, "seq"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_nohost, "nohost"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_gang, "gang"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps15(*this, tblgen_gangDim, "gangDim"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_gangDimDeviceType, "gangDimDeviceType"))) return ::mlir::failure(); return ::mlir::success(); } ::llvm::LogicalResult RoutineOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult RoutineOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::StringAttr sym_nameAttr; ::mlir::SymbolRefAttr func_nameAttr; ::mlir::ArrayAttr bindIdNameAttr; ::mlir::ArrayAttr bindStrNameAttr; ::mlir::ArrayAttr bindIdNameDeviceTypeAttr; ::mlir::ArrayAttr bindStrNameDeviceTypeAttr; ::mlir::ArrayAttr gangAttr; ::mlir::ArrayAttr gangDimAttr; ::mlir::ArrayAttr gangDimDeviceTypeAttr; ::mlir::ArrayAttr workerAttr; ::mlir::ArrayAttr vectorAttr; ::mlir::ArrayAttr seqAttr; if (parser.parseSymbolName(sym_nameAttr)) return ::mlir::failure(); if (sym_nameAttr) result.getOrAddProperties().sym_name = sym_nameAttr; if (parser.parseKeyword("func")) return ::mlir::failure(); if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseCustomAttributeWithFallback(func_nameAttr, parser.getBuilder().getType<::mlir::NoneType>())) { return ::mlir::failure(); } if (func_nameAttr) result.getOrAddProperties().func_name = func_nameAttr; if (parser.parseRParen()) return ::mlir::failure(); bool bindClause = false; bool gangClause = false; bool workerClause = false; bool vectorClause = false; bool seqClause = false; bool nohostClause = false; bool implicitClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("bind"))) { if (bindClause) { return parser.emitError(parser.getNameLoc()) << "`bind` clause can appear at most once in the expansion of the " "oilist directive"; } bindClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseBindName(parser, bindIdNameAttr, bindStrNameAttr, bindIdNameDeviceTypeAttr, bindStrNameDeviceTypeAttr); if (odsResult) return ::mlir::failure(); if (bindIdNameAttr) result.getOrAddProperties().bindIdName = bindIdNameAttr; if (bindStrNameAttr) result.getOrAddProperties().bindStrName = bindStrNameAttr; if (bindIdNameDeviceTypeAttr) result.getOrAddProperties().bindIdNameDeviceType = bindIdNameDeviceTypeAttr; if (bindStrNameDeviceTypeAttr) result.getOrAddProperties().bindStrNameDeviceType = bindStrNameDeviceTypeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("gang"))) { if (gangClause) { return parser.emitError(parser.getNameLoc()) << "`gang` clause can appear at most once in the expansion of the " "oilist directive"; } gangClause = true; { auto odsResult = parseRoutineGangClause(parser, gangAttr, gangDimAttr, gangDimDeviceTypeAttr); if (odsResult) return ::mlir::failure(); if (gangAttr) result.getOrAddProperties().gang = gangAttr; if (gangDimAttr) result.getOrAddProperties().gangDim = gangDimAttr; if (gangDimDeviceTypeAttr) result.getOrAddProperties().gangDimDeviceType = gangDimDeviceTypeAttr; } } else if (succeeded(parser.parseOptionalKeyword("worker"))) { if (workerClause) { return parser.emitError(parser.getNameLoc()) << "`worker` clause can appear at most once in the expansion of the " "oilist directive"; } workerClause = true; { auto odsResult = parseDeviceTypeArrayAttr(parser, workerAttr); if (odsResult) return ::mlir::failure(); if (workerAttr) result.getOrAddProperties().worker = workerAttr; } } else if (succeeded(parser.parseOptionalKeyword("vector"))) { if (vectorClause) { return parser.emitError(parser.getNameLoc()) << "`vector` clause can appear at most once in the expansion of the " "oilist directive"; } vectorClause = true; { auto odsResult = parseDeviceTypeArrayAttr(parser, vectorAttr); if (odsResult) return ::mlir::failure(); if (vectorAttr) result.getOrAddProperties().vector = vectorAttr; } } else if (succeeded(parser.parseOptionalKeyword("seq"))) { if (seqClause) { return parser.emitError(parser.getNameLoc()) << "`seq` clause can appear at most once in the expansion of the " "oilist directive"; } seqClause = true; { auto odsResult = parseDeviceTypeArrayAttr(parser, seqAttr); if (odsResult) return ::mlir::failure(); if (seqAttr) result.getOrAddProperties().seq = seqAttr; } } else if (succeeded(parser.parseOptionalKeyword("nohost"))) { if (nohostClause) { return parser.emitError(parser.getNameLoc()) << "`nohost` clause can appear at most once in the expansion of the " "oilist directive"; } nohostClause = true; result.getOrAddProperties().nohost = parser.getBuilder().getUnitAttr(); } else if (succeeded(parser.parseOptionalKeyword("implicit"))) { if (implicitClause) { return parser.emitError(parser.getNameLoc()) << "`implicit` clause can appear at most once in the expansion of the " "oilist directive"; } implicitClause = true; result.getOrAddProperties().implicit = parser.getBuilder().getUnitAttr(); } else { break; } } { 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(); } return ::mlir::success(); } void RoutineOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter.printSymbolName(getSymNameAttr().getValue()); _odsPrinter << ' ' << "func"; _odsPrinter << "("; _odsPrinter.printAttributeWithoutType(getFuncNameAttr()); _odsPrinter << ")"; if (false || (getBindIdNameAttr()) || (getBindStrNameAttr()) || (getBindIdNameDeviceTypeAttr()) || (getBindStrNameDeviceTypeAttr())) { _odsPrinter << ' ' << "bind"; _odsPrinter << "("; printBindName(_odsPrinter, *this, getBindIdNameAttr(), getBindStrNameAttr(), getBindIdNameDeviceTypeAttr(), getBindStrNameDeviceTypeAttr()); _odsPrinter << ")"; } if (false || (getGangAttr()) || (getGangDimAttr()) || (getGangDimDeviceTypeAttr())) { _odsPrinter << ' ' << "gang"; printRoutineGangClause(_odsPrinter, *this, getGangAttr(), getGangDimAttr(), getGangDimDeviceTypeAttr()); } if (false || (getWorkerAttr())) { _odsPrinter << ' ' << "worker"; _odsPrinter << ' '; printDeviceTypeArrayAttr(_odsPrinter, *this, getWorkerAttr()); } if (false || (getVectorAttr())) { _odsPrinter << ' ' << "vector"; _odsPrinter << ' '; printDeviceTypeArrayAttr(_odsPrinter, *this, getVectorAttr()); } if (false || (getSeqAttr())) { _odsPrinter << ' ' << "seq"; _odsPrinter << ' '; printDeviceTypeArrayAttr(_odsPrinter, *this, getSeqAttr()); } if (false || ((getNohostAttr() && getNohostAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) { _odsPrinter << ' ' << "nohost"; } if (false || ((getImplicitAttr() && getImplicitAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) { _odsPrinter << ' ' << "implicit"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("sym_name"); elidedAttrs.push_back("func_name"); elidedAttrs.push_back("bindIdName"); elidedAttrs.push_back("bindStrName"); elidedAttrs.push_back("bindIdNameDeviceType"); elidedAttrs.push_back("bindStrNameDeviceType"); elidedAttrs.push_back("gang"); elidedAttrs.push_back("gangDim"); elidedAttrs.push_back("gangDimDeviceType"); elidedAttrs.push_back("worker"); elidedAttrs.push_back("vector"); elidedAttrs.push_back("seq"); elidedAttrs.push_back("nohost"); elidedAttrs.push_back("implicit"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getNohostAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("nohost"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("implicit"); } _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::RoutineOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::RoutineOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::SerialOp definitions //===----------------------------------------------------------------------===// namespace detail { SerialOpGenericAdaptorBase::SerialOpGenericAdaptorBase(SerialOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair SerialOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::std::optional< ::mlir::ArrayAttr > SerialOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > SerialOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> SerialOpGenericAdaptorBase::getWaitOperandsSegments() { auto attr = getWaitOperandsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > SerialOpGenericAdaptorBase::getWaitOperandsDeviceType() { auto attr = getWaitOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > SerialOpGenericAdaptorBase::getHasWaitDevnum() { auto attr = getHasWaitDevnumAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > SerialOpGenericAdaptorBase::getWaitOnly() { auto attr = getWaitOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::UnitAttr SerialOpGenericAdaptorBase::getSelfAttrAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().selfAttr); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool SerialOpGenericAdaptorBase::getSelfAttr() { auto attr = getSelfAttrAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::std::optional<::mlir::acc::ClauseDefaultValue> SerialOpGenericAdaptorBase::getDefaultAttr() { auto attr = getDefaultAttrAttr(); return attr ? ::std::optional<::mlir::acc::ClauseDefaultValue>(attr.getValue()) : (::std::nullopt); } ::mlir::UnitAttr SerialOpGenericAdaptorBase::getCombinedAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().combined); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool SerialOpGenericAdaptorBase::getCombined() { auto attr = getCombinedAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail SerialOpAdaptor::SerialOpAdaptor(SerialOp op) : SerialOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SerialOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_combined = getProperties().combined; (void)tblgen_combined; auto tblgen_defaultAttr = getProperties().defaultAttr; (void)tblgen_defaultAttr; auto tblgen_hasWaitDevnum = getProperties().hasWaitDevnum; (void)tblgen_hasWaitDevnum; auto tblgen_selfAttr = getProperties().selfAttr; (void)tblgen_selfAttr; auto tblgen_waitOnly = getProperties().waitOnly; (void)tblgen_waitOnly; auto tblgen_waitOperandsDeviceType = getProperties().waitOperandsDeviceType; (void)tblgen_waitOperandsDeviceType; auto tblgen_waitOperandsSegments = getProperties().waitOperandsSegments; (void)tblgen_waitOperandsSegments; if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.serial' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.serial' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_waitOperandsSegments && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_waitOperandsSegments)))) return emitError(loc, "'acc.serial' op attribute 'waitOperandsSegments' failed to satisfy constraint: i32 dense array attribute"); if (tblgen_waitOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_waitOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_waitOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.serial' op attribute 'waitOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_hasWaitDevnum && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_hasWaitDevnum))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_hasWaitDevnum), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::BoolAttr>(attr))); })))) return emitError(loc, "'acc.serial' op attribute 'hasWaitDevnum' failed to satisfy constraint: 1-bit boolean array attribute"); if (tblgen_waitOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_waitOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_waitOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.serial' op attribute 'waitOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_selfAttr && !((::llvm::isa<::mlir::UnitAttr>(tblgen_selfAttr)))) return emitError(loc, "'acc.serial' op attribute 'selfAttr' failed to satisfy constraint: unit attribute"); if (tblgen_defaultAttr && !((::llvm::isa<::mlir::acc::ClauseDefaultValueAttr>(tblgen_defaultAttr)))) return emitError(loc, "'acc.serial' op attribute 'defaultAttr' failed to satisfy constraint: DefaultValue Clause"); if (tblgen_combined && !((::llvm::isa<::mlir::UnitAttr>(tblgen_combined)))) return emitError(loc, "'acc.serial' op attribute 'combined' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } std::pair SerialOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange SerialOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange SerialOp::getWaitOperandsMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange SerialOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange SerialOp::getSelfCondMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange SerialOp::getReductionOperandsMutable() { auto range = getODSOperandIndexAndLength(4); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(4u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange SerialOp::getPrivateOperandsMutable() { auto range = getODSOperandIndexAndLength(5); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(5u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange SerialOp::getFirstprivateOperandsMutable() { auto range = getODSOperandIndexAndLength(6); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(6u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange SerialOp::getDataClauseOperandsMutable() { auto range = getODSOperandIndexAndLength(7); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(7u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult SerialOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.combined; auto attr = dict.get("combined"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `combined` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.defaultAttr; auto attr = dict.get("defaultAttr"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `defaultAttr` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.hasWaitDevnum; auto attr = dict.get("hasWaitDevnum"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `hasWaitDevnum` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.selfAttr; auto attr = dict.get("selfAttr"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `selfAttr` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOnly; auto attr = dict.get("waitOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOperandsDeviceType; auto attr = dict.get("waitOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOperandsSegments; auto attr = dict.get("waitOperandsSegments"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOperandsSegments` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute SerialOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.combined; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("combined", propStorage)); } { const auto &propStorage = prop.defaultAttr; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("defaultAttr", propStorage)); } { const auto &propStorage = prop.hasWaitDevnum; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("hasWaitDevnum", propStorage)); } { const auto &propStorage = prop.selfAttr; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("selfAttr", propStorage)); } { const auto &propStorage = prop.waitOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOnly", propStorage)); } { const auto &propStorage = prop.waitOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.waitOperandsSegments; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOperandsSegments", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code SerialOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.combined.getAsOpaquePointer()), llvm::hash_value(prop.defaultAttr.getAsOpaquePointer()), llvm::hash_value(prop.hasWaitDevnum.getAsOpaquePointer()), llvm::hash_value(prop.selfAttr.getAsOpaquePointer()), llvm::hash_value(prop.waitOnly.getAsOpaquePointer()), llvm::hash_value(prop.waitOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.waitOperandsSegments.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional SerialOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "combined") return prop.combined; if (name == "defaultAttr") return prop.defaultAttr; if (name == "hasWaitDevnum") return prop.hasWaitDevnum; if (name == "selfAttr") return prop.selfAttr; if (name == "waitOnly") return prop.waitOnly; if (name == "waitOperandsDeviceType") return prop.waitOperandsDeviceType; if (name == "waitOperandsSegments") return prop.waitOperandsSegments; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void SerialOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "combined") { prop.combined = ::llvm::dyn_cast_or_null>(value); return; } if (name == "defaultAttr") { prop.defaultAttr = ::llvm::dyn_cast_or_null>(value); return; } if (name == "hasWaitDevnum") { prop.hasWaitDevnum = ::llvm::dyn_cast_or_null>(value); return; } if (name == "selfAttr") { prop.selfAttr = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOnly") { prop.waitOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOperandsDeviceType") { prop.waitOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOperandsSegments") { prop.waitOperandsSegments = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void SerialOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.combined) attrs.append("combined", prop.combined); if (prop.defaultAttr) attrs.append("defaultAttr", prop.defaultAttr); if (prop.hasWaitDevnum) attrs.append("hasWaitDevnum", prop.hasWaitDevnum); if (prop.selfAttr) attrs.append("selfAttr", prop.selfAttr); if (prop.waitOnly) attrs.append("waitOnly", prop.waitOnly); if (prop.waitOperandsDeviceType) attrs.append("waitOperandsDeviceType", prop.waitOperandsDeviceType); if (prop.waitOperandsSegments) attrs.append("waitOperandsSegments", prop.waitOperandsSegments); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult SerialOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getCombinedAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "combined", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDefaultAttrAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps11(attr, "defaultAttr", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getHasWaitDevnumAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps10(attr, "hasWaitDevnum", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getSelfAttrAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "selfAttr", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "waitOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "waitOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOperandsSegmentsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(attr, "waitOperandsSegments", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult SerialOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.combined))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.defaultAttr))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.hasWaitDevnum))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.selfAttr))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.waitOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.waitOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.waitOperandsSegments))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void SerialOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.combined); writer.writeOptionalAttribute(prop.defaultAttr); writer.writeOptionalAttribute(prop.hasWaitDevnum); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.selfAttr); writer.writeOptionalAttribute(prop.waitOnly); writer.writeOptionalAttribute(prop.waitOperandsDeviceType); writer.writeOptionalAttribute(prop.waitOperandsSegments); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::std::optional< ::mlir::ArrayAttr > SerialOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > SerialOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> SerialOp::getWaitOperandsSegments() { auto attr = getWaitOperandsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > SerialOp::getWaitOperandsDeviceType() { auto attr = getWaitOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > SerialOp::getHasWaitDevnum() { auto attr = getHasWaitDevnumAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > SerialOp::getWaitOnly() { auto attr = getWaitOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } bool SerialOp::getSelfAttr() { auto attr = getSelfAttrAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } ::std::optional<::mlir::acc::ClauseDefaultValue> SerialOp::getDefaultAttr() { auto attr = getDefaultAttrAttr(); return attr ? ::std::optional<::mlir::acc::ClauseDefaultValue>(attr.getValue()) : (::std::nullopt); } bool SerialOp::getCombined() { auto attr = getCombinedAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void SerialOp::setWaitOperandsSegments(::std::optional<::llvm::ArrayRef> attrValue) { auto &odsProp = getProperties().waitOperandsSegments; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(*attrValue); else odsProp = nullptr; } void SerialOp::setSelfAttr(bool attrValue) { auto &odsProp = getProperties().selfAttr; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void SerialOp::setDefaultAttr(::std::optional<::mlir::acc::ClauseDefaultValue> attrValue) { auto &odsProp = getProperties().defaultAttr; if (attrValue) odsProp = ::mlir::acc::ClauseDefaultValueAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void SerialOp::setCombined(bool attrValue) { auto &odsProp = getProperties().combined; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void SerialOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); if (ifCond) odsState.addOperands(ifCond); if (selfCond) odsState.addOperands(selfCond); odsState.addOperands(reductionOperands); odsState.addOperands(privateOperands); odsState.addOperands(firstprivateOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(asyncOperands.size()), static_cast(waitOperands.size()), (ifCond ? 1 : 0), (selfCond ? 1 : 0), static_cast(reductionOperands.size()), static_cast(privateOperands.size()), static_cast(firstprivateOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (selfAttr) { odsState.getOrAddProperties().selfAttr = selfAttr; } if (defaultAttr) { odsState.getOrAddProperties().defaultAttr = defaultAttr; } if (combined) { odsState.getOrAddProperties().combined = combined; } (void)odsState.addRegion(); } SerialOp SerialOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SerialOp SerialOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { return create(builder, builder.getLoc(), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); } void SerialOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); if (ifCond) odsState.addOperands(ifCond); if (selfCond) odsState.addOperands(selfCond); odsState.addOperands(reductionOperands); odsState.addOperands(privateOperands); odsState.addOperands(firstprivateOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(asyncOperands.size()), static_cast(waitOperands.size()), (ifCond ? 1 : 0), (selfCond ? 1 : 0), static_cast(reductionOperands.size()), static_cast(privateOperands.size()), static_cast(firstprivateOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (selfAttr) { odsState.getOrAddProperties().selfAttr = selfAttr; } if (defaultAttr) { odsState.getOrAddProperties().defaultAttr = defaultAttr; } if (combined) { odsState.getOrAddProperties().combined = combined; } (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } SerialOp SerialOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SerialOp SerialOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/::mlir::UnitAttr selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/::mlir::UnitAttr combined) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); } void SerialOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); if (ifCond) odsState.addOperands(ifCond); if (selfCond) odsState.addOperands(selfCond); odsState.addOperands(reductionOperands); odsState.addOperands(privateOperands); odsState.addOperands(firstprivateOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(asyncOperands.size()), static_cast(waitOperands.size()), (ifCond ? 1 : 0), (selfCond ? 1 : 0), static_cast(reductionOperands.size()), static_cast(privateOperands.size()), static_cast(firstprivateOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (selfAttr) { odsState.getOrAddProperties().selfAttr = ((selfAttr) ? odsBuilder.getUnitAttr() : nullptr); } if (defaultAttr) { odsState.getOrAddProperties().defaultAttr = defaultAttr; } if (combined) { odsState.getOrAddProperties().combined = ((combined) ? odsBuilder.getUnitAttr() : nullptr); } (void)odsState.addRegion(); } SerialOp SerialOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SerialOp SerialOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { return create(builder, builder.getLoc(), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); } void SerialOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); if (ifCond) odsState.addOperands(ifCond); if (selfCond) odsState.addOperands(selfCond); odsState.addOperands(reductionOperands); odsState.addOperands(privateOperands); odsState.addOperands(firstprivateOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({static_cast(asyncOperands.size()), static_cast(waitOperands.size()), (ifCond ? 1 : 0), (selfCond ? 1 : 0), static_cast(reductionOperands.size()), static_cast(privateOperands.size()), static_cast(firstprivateOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (selfAttr) { odsState.getOrAddProperties().selfAttr = ((selfAttr) ? odsBuilder.getUnitAttr() : nullptr); } if (defaultAttr) { odsState.getOrAddProperties().defaultAttr = defaultAttr; } if (combined) { odsState.getOrAddProperties().combined = ((combined) ? odsBuilder.getUnitAttr() : nullptr); } (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } SerialOp SerialOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SerialOp SerialOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, /*optional*/::mlir::Value ifCond, /*optional*/::mlir::Value selfCond, /*optional*/bool selfAttr, ::mlir::ValueRange reductionOperands, ::mlir::ValueRange privateOperands, ::mlir::ValueRange firstprivateOperands, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::acc::ClauseDefaultValueAttr defaultAttr, /*optional*/bool combined) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(ifCond), std::forward(selfCond), std::forward(selfAttr), std::forward(reductionOperands), std::forward(privateOperands), std::forward(firstprivateOperands), std::forward(dataClauseOperands), std::forward(defaultAttr), std::forward(combined)); } void SerialOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } SerialOp SerialOp::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__; } SerialOp SerialOp::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 SerialOp::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); for (unsigned i = 0; i != 1; ++i) (void)odsState.addRegion(); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } SerialOp SerialOp::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__; } SerialOp SerialOp::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 SerialOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_combined = getProperties().combined; (void)tblgen_combined; auto tblgen_defaultAttr = getProperties().defaultAttr; (void)tblgen_defaultAttr; auto tblgen_hasWaitDevnum = getProperties().hasWaitDevnum; (void)tblgen_hasWaitDevnum; auto tblgen_selfAttr = getProperties().selfAttr; (void)tblgen_selfAttr; auto tblgen_waitOnly = getProperties().waitOnly; (void)tblgen_waitOnly; auto tblgen_waitOperandsDeviceType = getProperties().waitOperandsDeviceType; (void)tblgen_waitOperandsDeviceType; auto tblgen_waitOperandsSegments = getProperties().waitOperandsSegments; (void)tblgen_waitOperandsSegments; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(*this, tblgen_waitOperandsSegments, "waitOperandsSegments"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_waitOperandsDeviceType, "waitOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps10(*this, tblgen_hasWaitDevnum, "hasWaitDevnum"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_waitOnly, "waitOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_selfAttr, "selfAttr"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps11(*this, tblgen_defaultAttr, "defaultAttr"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_combined, "combined"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); if (valueGroup2.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup2.size(); } for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); if (valueGroup3.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup3.size(); } for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup4 = getODSOperands(4); for (auto v : valueGroup4) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup5 = getODSOperands(5); for (auto v : valueGroup5) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup6 = getODSOperands(6); for (auto v : valueGroup6) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup7 = getODSOperands(7); for (auto v : valueGroup7) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_OpenACCOps2(*this, region, "region", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult SerialOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult SerialOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dataClauseOperandsOperands; ::llvm::SMLoc dataClauseOperandsOperandsLoc; (void)dataClauseOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> dataClauseOperandsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> firstprivateOperandsOperands; ::llvm::SMLoc firstprivateOperandsOperandsLoc; (void)firstprivateOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> firstprivateOperandsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> privateOperandsOperands; ::llvm::SMLoc privateOperandsOperandsLoc; (void)privateOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> privateOperandsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> waitOperandsOperands; ::llvm::SMLoc waitOperandsOperandsLoc; (void)waitOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> waitOperandsTypes; ::mlir::ArrayAttr waitOperandsDeviceTypeAttr; ::mlir::DenseI32ArrayAttr waitOperandsSegmentsAttr; ::mlir::ArrayAttr hasWaitDevnumAttr; ::mlir::ArrayAttr waitOnlyAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> selfCondOperands; ::llvm::SMLoc selfCondOperandsLoc; (void)selfCondOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> reductionOperandsOperands; ::llvm::SMLoc reductionOperandsOperandsLoc; (void)reductionOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> reductionOperandsTypes; std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); if (::mlir::succeeded(parser.parseOptionalKeyword("combined"))) { result.getOrAddProperties().combined = parser.getBuilder().getUnitAttr(); if (parser.parseLParen()) return ::mlir::failure(); if (parser.parseKeyword("loop")) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } bool dataOperandsClause = false; bool asyncClause = false; bool firstprivateClause = false; bool privateClause = false; bool waitClause = false; bool selfClause = false; bool ifClause = false; bool reductionClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("dataOperands"))) { if (dataOperandsClause) { return parser.emitError(parser.getNameLoc()) << "`dataOperands` clause can appear at most once in the expansion of the " "oilist directive"; } dataOperandsClause = true; if (parser.parseLParen()) return ::mlir::failure(); dataClauseOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(dataClauseOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(dataClauseOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("firstprivate"))) { if (firstprivateClause) { return parser.emitError(parser.getNameLoc()) << "`firstprivate` clause can appear at most once in the expansion of the " "oilist directive"; } firstprivateClause = true; if (parser.parseLParen()) return ::mlir::failure(); firstprivateOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(firstprivateOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(firstprivateOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("private"))) { if (privateClause) { return parser.emitError(parser.getNameLoc()) << "`private` clause can appear at most once in the expansion of the " "oilist directive"; } privateClause = true; if (parser.parseLParen()) return ::mlir::failure(); privateOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(privateOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(privateOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("wait"))) { if (waitClause) { return parser.emitError(parser.getNameLoc()) << "`wait` clause can appear at most once in the expansion of the " "oilist directive"; } waitClause = true; { waitOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseWaitClause(parser, waitOperandsOperands, waitOperandsTypes, waitOperandsDeviceTypeAttr, waitOperandsSegmentsAttr, hasWaitDevnumAttr, waitOnlyAttr); if (odsResult) return ::mlir::failure(); if (waitOperandsDeviceTypeAttr) result.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceTypeAttr; if (waitOperandsSegmentsAttr) result.getOrAddProperties().waitOperandsSegments = waitOperandsSegmentsAttr; if (hasWaitDevnumAttr) result.getOrAddProperties().hasWaitDevnum = hasWaitDevnumAttr; if (waitOnlyAttr) result.getOrAddProperties().waitOnly = waitOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("self"))) { if (selfClause) { return parser.emitError(parser.getNameLoc()) << "`self` clause can appear at most once in the expansion of the " "oilist directive"; } selfClause = true; if (parser.parseLParen()) return ::mlir::failure(); { selfCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); selfCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("reduction"))) { if (reductionClause) { return parser.emitError(parser.getNameLoc()) << "`reduction` clause can appear at most once in the expansion of the " "oilist directive"; } reductionClause = true; if (parser.parseLParen()) return ::mlir::failure(); reductionOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(reductionOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(reductionOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseRegion(*regionRegion)) return ::mlir::failure(); { 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(); } result.addRegion(std::move(regionRegion)); ::llvm::copy(::llvm::ArrayRef({static_cast(asyncOperandsOperands.size()), static_cast(waitOperandsOperands.size()), static_cast(ifCondOperands.size()), static_cast(selfCondOperands.size()), static_cast(reductionOperandsOperands.size()), static_cast(privateOperandsOperands.size()), static_cast(firstprivateOperandsOperands.size()), static_cast(dataClauseOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(waitOperandsOperands, waitOperandsTypes, waitOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } if (!selfCondOperands.empty()) { if (parser.resolveOperands(selfCondOperands, odsBuildableType0, selfCondOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(reductionOperandsOperands, reductionOperandsTypes, reductionOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(privateOperandsOperands, privateOperandsTypes, privateOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(firstprivateOperandsOperands, firstprivateOperandsTypes, firstprivateOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(dataClauseOperandsOperands, dataClauseOperandsTypes, dataClauseOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void SerialOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if ((getCombinedAttr() && getCombinedAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) { _odsPrinter << ' ' << "combined"; _odsPrinter << "("; _odsPrinter << "loop"; _odsPrinter << ")"; } if (false || getDataClauseOperands().size()) { _odsPrinter << ' ' << "dataOperands"; _odsPrinter << "("; _odsPrinter << getDataClauseOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getDataClauseOperands().getTypes(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || getFirstprivateOperands().size()) { _odsPrinter << ' ' << "firstprivate"; _odsPrinter << "("; _odsPrinter << getFirstprivateOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getFirstprivateOperands().getTypes(); _odsPrinter << ")"; } if (false || getPrivateOperands().size()) { _odsPrinter << ' ' << "private"; _odsPrinter << "("; _odsPrinter << getPrivateOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getPrivateOperands().getTypes(); _odsPrinter << ")"; } if (false || getWaitOperands().size() || (getWaitOperandsDeviceTypeAttr()) || (getWaitOperandsSegmentsAttr()) || (getHasWaitDevnumAttr()) || (getWaitOnlyAttr())) { _odsPrinter << ' ' << "wait"; printWaitClause(_odsPrinter, *this, getWaitOperands(), getWaitOperands().getTypes(), getWaitOperandsDeviceTypeAttr(), getWaitOperandsSegmentsAttr(), getHasWaitDevnumAttr(), getWaitOnlyAttr()); } if (false || getSelfCond()) { _odsPrinter << ' ' << "self"; _odsPrinter << "("; if (::mlir::Value value = getSelfCond()) _odsPrinter << value; _odsPrinter << ")"; } if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } if (false || getReductionOperands().size()) { _odsPrinter << ' ' << "reduction"; _odsPrinter << "("; _odsPrinter << getReductionOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getReductionOperands().getTypes(); _odsPrinter << ")"; } _odsPrinter << ' '; _odsPrinter.printRegion(getRegion()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("combined"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("waitOperandsDeviceType"); elidedAttrs.push_back("waitOperandsSegments"); elidedAttrs.push_back("hasWaitDevnum"); elidedAttrs.push_back("waitOnly"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getSelfAttrAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("selfAttr"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getCombinedAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("combined"); } _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } void SerialOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::acc::ConstructResource::get()); effects.emplace_back(::mlir::MemoryEffects::Read::get(), 0, false, ::mlir::acc::CurrentDeviceIdResource::get()); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::SerialOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::SerialOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::SetOp definitions //===----------------------------------------------------------------------===// namespace detail { SetOpGenericAdaptorBase::SetOpGenericAdaptorBase(SetOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair SetOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::std::optional<::mlir::acc::DeviceType> SetOpGenericAdaptorBase::getDeviceType() { auto attr = getDeviceTypeAttr(); return attr ? ::std::optional<::mlir::acc::DeviceType>(attr.getValue()) : (::std::nullopt); } } // namespace detail SetOpAdaptor::SetOpAdaptor(SetOp op) : SetOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult SetOpAdaptor::verify(::mlir::Location loc) { auto tblgen_device_type = getProperties().device_type; (void)tblgen_device_type; if (tblgen_device_type && !((::llvm::isa<::mlir::acc::DeviceTypeAttr>(tblgen_device_type)))) return emitError(loc, "'acc.set' op attribute 'device_type' failed to satisfy constraint: built-in device type supported by OpenACC"); return ::mlir::success(); } std::pair SetOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange SetOp::getDefaultAsyncMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange SetOp::getDeviceNumMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange SetOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult SetOp::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.device_type; auto attr = dict.get("device_type"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `device_type` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute SetOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.device_type; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("device_type", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code SetOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.device_type.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional SetOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "device_type") return prop.device_type; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void SetOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "device_type") { prop.device_type = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void SetOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.device_type) attrs.append("device_type", prop.device_type); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult SetOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps23(attr, "device_type", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult SetOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.device_type))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void SetOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.device_type); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::std::optional<::mlir::acc::DeviceType> SetOp::getDeviceType() { auto attr = getDeviceTypeAttr(); return attr ? ::std::optional<::mlir::acc::DeviceType>(attr.getValue()) : (::std::nullopt); } void SetOp::setDeviceType(::std::optional<::mlir::acc::DeviceType> attrValue) { auto &odsProp = getProperties().device_type; if (attrValue) odsProp = ::mlir::acc::DeviceTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); else odsProp = nullptr; } void SetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::acc::DeviceTypeAttr device_type, /*optional*/::mlir::Value defaultAsync, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { if (defaultAsync) odsState.addOperands(defaultAsync); if (deviceNum) odsState.addOperands(deviceNum); if (ifCond) odsState.addOperands(ifCond); ::llvm::copy(::llvm::ArrayRef({(defaultAsync ? 1 : 0), (deviceNum ? 1 : 0), (ifCond ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (device_type) { odsState.getOrAddProperties().device_type = device_type; } } SetOp SetOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::acc::DeviceTypeAttr device_type, /*optional*/::mlir::Value defaultAsync, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(device_type), std::forward(defaultAsync), std::forward(deviceNum), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SetOp SetOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::acc::DeviceTypeAttr device_type, /*optional*/::mlir::Value defaultAsync, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(device_type), std::forward(defaultAsync), std::forward(deviceNum), std::forward(ifCond)); } void SetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::acc::DeviceTypeAttr device_type, /*optional*/::mlir::Value defaultAsync, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { if (defaultAsync) odsState.addOperands(defaultAsync); if (deviceNum) odsState.addOperands(deviceNum); if (ifCond) odsState.addOperands(ifCond); ::llvm::copy(::llvm::ArrayRef({(defaultAsync ? 1 : 0), (deviceNum ? 1 : 0), (ifCond ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (device_type) { odsState.getOrAddProperties().device_type = device_type; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } SetOp SetOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::acc::DeviceTypeAttr device_type, /*optional*/::mlir::Value defaultAsync, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(device_type), std::forward(defaultAsync), std::forward(deviceNum), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } SetOp SetOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::acc::DeviceTypeAttr device_type, /*optional*/::mlir::Value defaultAsync, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(device_type), std::forward(defaultAsync), std::forward(deviceNum), std::forward(ifCond)); } void SetOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); 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."); } } SetOp SetOp::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__; } SetOp SetOp::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 SetOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } SetOp SetOp::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__; } SetOp SetOp::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 SetOp::verifyInvariantsImpl() { auto tblgen_device_type = getProperties().device_type; (void)tblgen_device_type; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps23(*this, tblgen_device_type, "device_type"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); if (valueGroup0.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup0.size(); } for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); if (valueGroup2.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup2.size(); } for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult SetOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult SetOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> defaultAsyncOperands; ::llvm::SMLoc defaultAsyncOperandsLoc; (void)defaultAsyncOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> defaultAsyncTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> deviceNumOperands; ::llvm::SMLoc deviceNumOperandsLoc; (void)deviceNumOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> deviceNumTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; bool default_asyncClause = false; bool device_numClause = false; bool ifClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("default_async"))) { if (default_asyncClause) { return parser.emitError(parser.getNameLoc()) << "`default_async` clause can appear at most once in the expansion of the " "oilist directive"; } default_asyncClause = true; if (parser.parseLParen()) return ::mlir::failure(); { defaultAsyncOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); defaultAsyncOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); defaultAsyncTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("device_num"))) { if (device_numClause) { return parser.emitError(parser.getNameLoc()) << "`device_num` clause can appear at most once in the expansion of the " "oilist directive"; } device_numClause = true; if (parser.parseLParen()) return ::mlir::failure(); { deviceNumOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); deviceNumOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); deviceNumTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } { 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(); } ::llvm::copy(::llvm::ArrayRef({static_cast(defaultAsyncOperands.size()), static_cast(deviceNumOperands.size()), static_cast(ifCondOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (!defaultAsyncOperands.empty()) { if (parser.resolveOperands(defaultAsyncOperands, defaultAsyncTypes, defaultAsyncOperandsLoc, result.operands)) return ::mlir::failure(); } if (!deviceNumOperands.empty()) { if (parser.resolveOperands(deviceNumOperands, deviceNumTypes, deviceNumOperandsLoc, result.operands)) return ::mlir::failure(); } if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void SetOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getDefaultAsync()) { _odsPrinter << ' ' << "default_async"; _odsPrinter << "("; if (::mlir::Value value = getDefaultAsync()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getDefaultAsync() ? ::llvm::ArrayRef<::mlir::Type>(getDefaultAsync().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getDeviceNum()) { _odsPrinter << ' ' << "device_num"; _odsPrinter << "("; if (::mlir::Value value = getDeviceNum()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getDeviceNum() ? ::llvm::ArrayRef<::mlir::Type>(getDeviceNum().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } void SetOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::acc::CurrentDeviceIdResource::get()); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::SetOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::SetOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::ShutdownOp definitions //===----------------------------------------------------------------------===// namespace detail { ShutdownOpGenericAdaptorBase::ShutdownOpGenericAdaptorBase(ShutdownOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair ShutdownOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::std::optional< ::mlir::ArrayAttr > ShutdownOpGenericAdaptorBase::getDeviceTypes() { auto attr = getDeviceTypesAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } } // namespace detail ShutdownOpAdaptor::ShutdownOpAdaptor(ShutdownOp op) : ShutdownOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult ShutdownOpAdaptor::verify(::mlir::Location loc) { auto tblgen_device_types = getProperties().device_types; (void)tblgen_device_types; if (tblgen_device_types && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_device_types))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_device_types), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.shutdown' op attribute 'device_types' failed to satisfy constraint: Device type attributes"); return ::mlir::success(); } std::pair ShutdownOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange ShutdownOp::getDeviceNumMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange ShutdownOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult ShutdownOp::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.device_types; auto attr = dict.get("device_types"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `device_types` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute ShutdownOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.device_types; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("device_types", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code ShutdownOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.device_types.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional ShutdownOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "device_types") return prop.device_types; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void ShutdownOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "device_types") { prop.device_types = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void ShutdownOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.device_types) attrs.append("device_types", prop.device_types); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult ShutdownOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getDeviceTypesAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps13(attr, "device_types", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ShutdownOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.device_types))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void ShutdownOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.device_types); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::std::optional< ::mlir::ArrayAttr > ShutdownOp::getDeviceTypes() { auto attr = getDeviceTypesAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } void ShutdownOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::ArrayAttr device_types, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { if (deviceNum) odsState.addOperands(deviceNum); if (ifCond) odsState.addOperands(ifCond); ::llvm::copy(::llvm::ArrayRef({(deviceNum ? 1 : 0), (ifCond ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (device_types) { odsState.getOrAddProperties().device_types = device_types; } } ShutdownOp ShutdownOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::ArrayAttr device_types, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(device_types), std::forward(deviceNum), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShutdownOp ShutdownOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::ArrayAttr device_types, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(device_types), std::forward(deviceNum), std::forward(ifCond)); } void ShutdownOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr device_types, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { if (deviceNum) odsState.addOperands(deviceNum); if (ifCond) odsState.addOperands(ifCond); ::llvm::copy(::llvm::ArrayRef({(deviceNum ? 1 : 0), (ifCond ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (device_types) { odsState.getOrAddProperties().device_types = device_types; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } ShutdownOp ShutdownOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr device_types, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(device_types), std::forward(deviceNum), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } ShutdownOp ShutdownOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::ArrayAttr device_types, /*optional*/::mlir::Value deviceNum, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(device_types), std::forward(deviceNum), std::forward(ifCond)); } void ShutdownOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); 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."); } } ShutdownOp ShutdownOp::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__; } ShutdownOp ShutdownOp::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 ShutdownOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } ShutdownOp ShutdownOp::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__; } ShutdownOp ShutdownOp::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 ShutdownOp::verifyInvariantsImpl() { auto tblgen_device_types = getProperties().device_types; (void)tblgen_device_types; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps13(*this, tblgen_device_types, "device_types"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); if (valueGroup0.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup0.size(); } for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult ShutdownOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult ShutdownOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> deviceNumOperands; ::llvm::SMLoc deviceNumOperandsLoc; (void)deviceNumOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> deviceNumTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; bool device_numClause = false; bool ifClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("device_num"))) { if (device_numClause) { return parser.emitError(parser.getNameLoc()) << "`device_num` clause can appear at most once in the expansion of the " "oilist directive"; } device_numClause = true; if (parser.parseLParen()) return ::mlir::failure(); { deviceNumOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); deviceNumOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); deviceNumTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } { 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(); } ::llvm::copy(::llvm::ArrayRef({static_cast(deviceNumOperands.size()), static_cast(ifCondOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (!deviceNumOperands.empty()) { if (parser.resolveOperands(deviceNumOperands, deviceNumTypes, deviceNumOperandsLoc, result.operands)) return ::mlir::failure(); } if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void ShutdownOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getDeviceNum()) { _odsPrinter << ' ' << "device_num"; _odsPrinter << "("; if (::mlir::Value value = getDeviceNum()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getDeviceNum() ? ::llvm::ArrayRef<::mlir::Type>(getDeviceNum().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::ShutdownOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::ShutdownOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::TerminatorOp definitions //===----------------------------------------------------------------------===// namespace detail { TerminatorOpGenericAdaptorBase::TerminatorOpGenericAdaptorBase(TerminatorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail TerminatorOpAdaptor::TerminatorOpAdaptor(TerminatorOp op) : TerminatorOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult TerminatorOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult TerminatorOp::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 TerminatorOp::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 TerminatorOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional TerminatorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void TerminatorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void TerminatorOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult TerminatorOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void TerminatorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { } TerminatorOp TerminatorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TerminatorOp TerminatorOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void TerminatorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } TerminatorOp TerminatorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } TerminatorOp TerminatorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes) { return create(builder, builder.getLoc(), std::forward(resultTypes)); } void TerminatorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } TerminatorOp TerminatorOp::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__; } TerminatorOp TerminatorOp::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 TerminatorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() == 0u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } TerminatorOp TerminatorOp::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__; } TerminatorOp TerminatorOp::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 TerminatorOp::verifyInvariantsImpl() { return ::mlir::success(); } ::llvm::LogicalResult TerminatorOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult TerminatorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } return ::mlir::success(); } void TerminatorOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } void TerminatorOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::TerminatorOp) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::UnwrapPrivateOp definitions //===----------------------------------------------------------------------===// namespace detail { UnwrapPrivateOpGenericAdaptorBase::UnwrapPrivateOpGenericAdaptorBase(UnwrapPrivateOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} } // namespace detail UnwrapPrivateOpAdaptor::UnwrapPrivateOpAdaptor(UnwrapPrivateOp op) : UnwrapPrivateOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult UnwrapPrivateOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } ::llvm::LogicalResult UnwrapPrivateOp::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 UnwrapPrivateOp::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 UnwrapPrivateOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional UnwrapPrivateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void UnwrapPrivateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void UnwrapPrivateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult UnwrapPrivateOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void UnwrapPrivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value handle) { odsState.addOperands(handle); odsState.addTypes(result); } UnwrapPrivateOp UnwrapPrivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value handle) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(result), std::forward(handle)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UnwrapPrivateOp UnwrapPrivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value handle) { return create(builder, builder.getLoc(), std::forward(result), std::forward(handle)); } void UnwrapPrivateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value handle) { odsState.addOperands(handle); assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } UnwrapPrivateOp UnwrapPrivateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value handle) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(handle)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UnwrapPrivateOp UnwrapPrivateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value handle) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(handle)); } void UnwrapPrivateOp::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); } UnwrapPrivateOp UnwrapPrivateOp::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__; } UnwrapPrivateOp UnwrapPrivateOp::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 UnwrapPrivateOp::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); } UnwrapPrivateOp UnwrapPrivateOp::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__; } UnwrapPrivateOp UnwrapPrivateOp::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 UnwrapPrivateOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps16(*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_OpenACCOps2(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult UnwrapPrivateOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult UnwrapPrivateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand handleRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> handleOperands(&handleRawOperand, 1); ::llvm::SMLoc handleOperandsLoc; (void)handleOperandsLoc; ::mlir::Type handleRawType{}; ::llvm::ArrayRef<::mlir::Type> handleTypes(&handleRawType, 1); ::mlir::Type resultRawType{}; ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); handleOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperand(handleRawOperand)) return ::mlir::failure(); { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); if (parser.parseType(handleRawType)) return ::mlir::failure(); if (parser.parseKeyword("to")) return ::mlir::failure(); { ::mlir::acc::PointerLikeType type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); resultRawType = type; } result.addTypes(resultTypes); if (parser.resolveOperands(handleOperands, handleTypes, handleOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void UnwrapPrivateOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; _odsPrinter << getHandle(); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getHandle().getType(); _odsPrinter << ' ' << "to"; _odsPrinter << ' '; { auto type = getResult().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::acc::PointerLikeType>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } } void UnwrapPrivateOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::UnwrapPrivateOp) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::UpdateDeviceOp definitions //===----------------------------------------------------------------------===// namespace detail { UpdateDeviceOpGenericAdaptorBase::UpdateDeviceOpGenericAdaptorBase(UpdateDeviceOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair UpdateDeviceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type UpdateDeviceOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > UpdateDeviceOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > UpdateDeviceOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr UpdateDeviceOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause UpdateDeviceOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr UpdateDeviceOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool UpdateDeviceOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr UpdateDeviceOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool UpdateDeviceOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr UpdateDeviceOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier UpdateDeviceOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > UpdateDeviceOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > UpdateDeviceOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail UpdateDeviceOpAdaptor::UpdateDeviceOpAdaptor(UpdateDeviceOp op) : UpdateDeviceOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult UpdateDeviceOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.update_device' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.update_device' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.update_device' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.update_device' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.update_device' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.update_device' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.update_device' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.update_device' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.update_device' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.update_device' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair UpdateDeviceOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange UpdateDeviceOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange UpdateDeviceOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange UpdateDeviceOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult UpdateDeviceOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute UpdateDeviceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code UpdateDeviceOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional UpdateDeviceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void UpdateDeviceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void UpdateDeviceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult UpdateDeviceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult UpdateDeviceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void UpdateDeviceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type UpdateDeviceOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > UpdateDeviceOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > UpdateDeviceOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause UpdateDeviceOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool UpdateDeviceOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool UpdateDeviceOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier UpdateDeviceOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > UpdateDeviceOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > UpdateDeviceOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void UpdateDeviceOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void UpdateDeviceOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void UpdateDeviceOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void UpdateDeviceOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void UpdateDeviceOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void UpdateDeviceOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void UpdateDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } UpdateDeviceOp UpdateDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateDeviceOp UpdateDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void UpdateDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } UpdateDeviceOp UpdateDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateDeviceOp UpdateDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void UpdateDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } UpdateDeviceOp UpdateDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateDeviceOp UpdateDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void UpdateDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } UpdateDeviceOp UpdateDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateDeviceOp UpdateDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void UpdateDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } UpdateDeviceOp UpdateDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateDeviceOp UpdateDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void UpdateDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } UpdateDeviceOp UpdateDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateDeviceOp UpdateDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void UpdateDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } UpdateDeviceOp UpdateDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateDeviceOp UpdateDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void UpdateDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } UpdateDeviceOp UpdateDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateDeviceOp UpdateDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void UpdateDeviceOp::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."); } } UpdateDeviceOp UpdateDeviceOp::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__; } UpdateDeviceOp UpdateDeviceOp::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 UpdateDeviceOp::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); } UpdateDeviceOp UpdateDeviceOp::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__; } UpdateDeviceOp UpdateDeviceOp::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 UpdateDeviceOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_update_device); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult UpdateDeviceOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult UpdateDeviceOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult UpdateDeviceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void UpdateDeviceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_update_device))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::UpdateDeviceOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::UpdateDeviceOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::UpdateHostOp definitions //===----------------------------------------------------------------------===// namespace detail { UpdateHostOpGenericAdaptorBase::UpdateHostOpGenericAdaptorBase(UpdateHostOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair UpdateHostOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type UpdateHostOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > UpdateHostOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > UpdateHostOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr UpdateHostOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause UpdateHostOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr UpdateHostOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool UpdateHostOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr UpdateHostOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool UpdateHostOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr UpdateHostOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier UpdateHostOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > UpdateHostOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } } // namespace detail UpdateHostOpAdaptor::UpdateHostOpAdaptor(UpdateHostOp op) : UpdateHostOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult UpdateHostOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.update_host' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.update_host' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.update_host' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.update_host' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.update_host' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.update_host' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.update_host' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.update_host' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.update_host' op attribute 'name' failed to satisfy constraint: string attribute"); return ::mlir::success(); } std::pair UpdateHostOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange UpdateHostOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange UpdateHostOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult UpdateHostOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute UpdateHostOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code UpdateHostOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional UpdateHostOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void UpdateHostOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void UpdateHostOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult UpdateHostOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult UpdateHostOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void UpdateHostOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type UpdateHostOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > UpdateHostOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > UpdateHostOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause UpdateHostOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool UpdateHostOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool UpdateHostOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier UpdateHostOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > UpdateHostOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } void UpdateHostOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void UpdateHostOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void UpdateHostOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void UpdateHostOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void UpdateHostOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void UpdateHostOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void UpdateHostOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, accVar, var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr); } UpdateHostOp UpdateHostOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateHostOp UpdateHostOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void UpdateHostOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, accVar, var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name)); } UpdateHostOp UpdateHostOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateHostOp UpdateHostOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void UpdateHostOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { build(odsBuilder, odsState, accVar, var, varType, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } UpdateHostOp UpdateHostOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateHostOp UpdateHostOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void UpdateHostOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::Value var, ::mlir::TypeAttr varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(var); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } } UpdateHostOp UpdateHostOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::Value var, ::mlir::TypeAttr varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateHostOp UpdateHostOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::Value var, ::mlir::TypeAttr varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void UpdateHostOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::Value var, ::mlir::TypeAttr varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(var); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } UpdateHostOp UpdateHostOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::Value var, ::mlir::TypeAttr varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateHostOp UpdateHostOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::Value var, ::mlir::TypeAttr varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void UpdateHostOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(var); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } } UpdateHostOp UpdateHostOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateHostOp UpdateHostOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void UpdateHostOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { odsState.addOperands(accVar); odsState.addOperands(var); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } UpdateHostOp UpdateHostOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateHostOp UpdateHostOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value accVar, ::mlir::Value var, ::mlir::Type varType, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void UpdateHostOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); if (!attributes.empty()) { (void)odsState.getOrAddProperties(); ::mlir::PropertyRef properties = odsState.getRawProperties(); std::optional<::mlir::RegisteredOperationName> info = odsState.name.getRegisteredInfo(); if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, odsState.attributes.getDictionary(odsState.getContext()), nullptr))) ::llvm::report_fatal_error("Property conversion failed."); } } UpdateHostOp UpdateHostOp::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__; } UpdateHostOp UpdateHostOp::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 UpdateHostOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { assert(operands.size() >= 2u && "mismatched number of parameters"); odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } UpdateHostOp UpdateHostOp::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__; } UpdateHostOp UpdateHostOp::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 UpdateHostOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_update_host); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult UpdateHostOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult UpdateHostOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult UpdateHostOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand accVarRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> accVarOperands(&accVarRawOperand, 1); ::llvm::SMLoc accVarOperandsLoc; (void)accVarOperandsLoc; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; { accVarOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseAccVar(parser, accVarRawOperand, accVarRawType); if (odsResult) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalKeyword("bounds"))) { if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } if (::mlir::succeeded(parser.parseOptionalKeyword("async"))) { { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } if (parser.parseKeyword("to")) return ::mlir::failure(); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } { 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(); } ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); if (parser.resolveOperands(accVarOperands, accVarTypes, accVarOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void UpdateHostOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printAccVar(_odsPrinter, *this, getAccVar(), getAccVar().getType()); if (!getBounds().empty()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (((!getAsyncOperands().empty()) || (!getAsyncOperands().empty()) || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr()))) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } _odsPrinter << ' ' << "to"; _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("varType"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_update_host))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::UpdateHostOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::UpdateHostOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::UpdateOp definitions //===----------------------------------------------------------------------===// namespace detail { UpdateOpGenericAdaptorBase::UpdateOpGenericAdaptorBase(UpdateOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair UpdateOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::std::optional< ::mlir::ArrayAttr > UpdateOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > UpdateOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> UpdateOpGenericAdaptorBase::getWaitOperandsSegments() { auto attr = getWaitOperandsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > UpdateOpGenericAdaptorBase::getWaitOperandsDeviceType() { auto attr = getWaitOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > UpdateOpGenericAdaptorBase::getHasWaitDevnum() { auto attr = getHasWaitDevnumAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > UpdateOpGenericAdaptorBase::getWaitOnly() { auto attr = getWaitOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::UnitAttr UpdateOpGenericAdaptorBase::getIfPresentAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().ifPresent); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool UpdateOpGenericAdaptorBase::getIfPresent() { auto attr = getIfPresentAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail UpdateOpAdaptor::UpdateOpAdaptor(UpdateOp op) : UpdateOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult UpdateOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_hasWaitDevnum = getProperties().hasWaitDevnum; (void)tblgen_hasWaitDevnum; auto tblgen_ifPresent = getProperties().ifPresent; (void)tblgen_ifPresent; auto tblgen_waitOnly = getProperties().waitOnly; (void)tblgen_waitOnly; auto tblgen_waitOperandsDeviceType = getProperties().waitOperandsDeviceType; (void)tblgen_waitOperandsDeviceType; auto tblgen_waitOperandsSegments = getProperties().waitOperandsSegments; (void)tblgen_waitOperandsSegments; if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.update' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.update' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_waitOperandsSegments && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_waitOperandsSegments)))) return emitError(loc, "'acc.update' op attribute 'waitOperandsSegments' failed to satisfy constraint: i32 dense array attribute"); if (tblgen_waitOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_waitOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_waitOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.update' op attribute 'waitOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_hasWaitDevnum && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_hasWaitDevnum))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_hasWaitDevnum), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::BoolAttr>(attr))); })))) return emitError(loc, "'acc.update' op attribute 'hasWaitDevnum' failed to satisfy constraint: 1-bit boolean array attribute"); if (tblgen_waitOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_waitOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_waitOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.update' op attribute 'waitOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_ifPresent && !((::llvm::isa<::mlir::UnitAttr>(tblgen_ifPresent)))) return emitError(loc, "'acc.update' op attribute 'ifPresent' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } std::pair UpdateOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange UpdateOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange UpdateOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange UpdateOp::getWaitOperandsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange UpdateOp::getDataClauseOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult UpdateOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.hasWaitDevnum; auto attr = dict.get("hasWaitDevnum"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `hasWaitDevnum` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.ifPresent; auto attr = dict.get("ifPresent"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `ifPresent` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOnly; auto attr = dict.get("waitOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOperandsDeviceType; auto attr = dict.get("waitOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.waitOperandsSegments; auto attr = dict.get("waitOperandsSegments"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `waitOperandsSegments` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute UpdateOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.hasWaitDevnum; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("hasWaitDevnum", propStorage)); } { const auto &propStorage = prop.ifPresent; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("ifPresent", propStorage)); } { const auto &propStorage = prop.waitOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOnly", propStorage)); } { const auto &propStorage = prop.waitOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.waitOperandsSegments; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("waitOperandsSegments", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code UpdateOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.hasWaitDevnum.getAsOpaquePointer()), llvm::hash_value(prop.ifPresent.getAsOpaquePointer()), llvm::hash_value(prop.waitOnly.getAsOpaquePointer()), llvm::hash_value(prop.waitOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.waitOperandsSegments.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional UpdateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "hasWaitDevnum") return prop.hasWaitDevnum; if (name == "ifPresent") return prop.ifPresent; if (name == "waitOnly") return prop.waitOnly; if (name == "waitOperandsDeviceType") return prop.waitOperandsDeviceType; if (name == "waitOperandsSegments") return prop.waitOperandsSegments; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void UpdateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "hasWaitDevnum") { prop.hasWaitDevnum = ::llvm::dyn_cast_or_null>(value); return; } if (name == "ifPresent") { prop.ifPresent = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOnly") { prop.waitOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOperandsDeviceType") { prop.waitOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "waitOperandsSegments") { prop.waitOperandsSegments = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void UpdateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.hasWaitDevnum) attrs.append("hasWaitDevnum", prop.hasWaitDevnum); if (prop.ifPresent) attrs.append("ifPresent", prop.ifPresent); if (prop.waitOnly) attrs.append("waitOnly", prop.waitOnly); if (prop.waitOperandsDeviceType) attrs.append("waitOperandsDeviceType", prop.waitOperandsDeviceType); if (prop.waitOperandsSegments) attrs.append("waitOperandsSegments", prop.waitOperandsSegments); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult UpdateOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getHasWaitDevnumAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps10(attr, "hasWaitDevnum", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getIfPresentAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "ifPresent", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "waitOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "waitOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getWaitOperandsSegmentsAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(attr, "waitOperandsSegments", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult UpdateOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.hasWaitDevnum))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.ifPresent))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.waitOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.waitOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.waitOperandsSegments))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void UpdateOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.hasWaitDevnum); writer.writeOptionalAttribute(prop.ifPresent); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.waitOnly); writer.writeOptionalAttribute(prop.waitOperandsDeviceType); writer.writeOptionalAttribute(prop.waitOperandsSegments); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::std::optional< ::mlir::ArrayAttr > UpdateOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > UpdateOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional<::llvm::ArrayRef> UpdateOp::getWaitOperandsSegments() { auto attr = getWaitOperandsSegmentsAttr(); return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > UpdateOp::getWaitOperandsDeviceType() { auto attr = getWaitOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > UpdateOp::getHasWaitDevnum() { auto attr = getHasWaitDevnumAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > UpdateOp::getWaitOnly() { auto attr = getWaitOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } bool UpdateOp::getIfPresent() { auto attr = getIfPresentAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void UpdateOp::setWaitOperandsSegments(::std::optional<::llvm::ArrayRef> attrValue) { auto &odsProp = getProperties().waitOperandsSegments; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(*attrValue); else odsProp = nullptr; } void UpdateOp::setIfPresent(bool attrValue) { auto &odsProp = getProperties().ifPresent; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void UpdateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr ifPresent) { if (ifCond) odsState.addOperands(ifCond); odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), static_cast(asyncOperands.size()), static_cast(waitOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (ifPresent) { odsState.getOrAddProperties().ifPresent = ifPresent; } } UpdateOp UpdateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr ifPresent) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ifCond), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(dataClauseOperands), std::forward(ifPresent)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateOp UpdateOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr ifPresent) { return create(builder, builder.getLoc(), std::forward(ifCond), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(dataClauseOperands), std::forward(ifPresent)); } void UpdateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr ifPresent) { if (ifCond) odsState.addOperands(ifCond); odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), static_cast(asyncOperands.size()), static_cast(waitOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (ifPresent) { odsState.getOrAddProperties().ifPresent = ifPresent; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } UpdateOp UpdateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr ifPresent) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ifCond), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(dataClauseOperands), std::forward(ifPresent)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateOp UpdateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/::mlir::UnitAttr ifPresent) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ifCond), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(dataClauseOperands), std::forward(ifPresent)); } void UpdateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/bool ifPresent) { if (ifCond) odsState.addOperands(ifCond); odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), static_cast(asyncOperands.size()), static_cast(waitOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (ifPresent) { odsState.getOrAddProperties().ifPresent = ((ifPresent) ? odsBuilder.getUnitAttr() : nullptr); } } UpdateOp UpdateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/bool ifPresent) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(ifCond), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(dataClauseOperands), std::forward(ifPresent)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateOp UpdateOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/bool ifPresent) { return create(builder, builder.getLoc(), std::forward(ifCond), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(dataClauseOperands), std::forward(ifPresent)); } void UpdateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/bool ifPresent) { if (ifCond) odsState.addOperands(ifCond); odsState.addOperands(asyncOperands); odsState.addOperands(waitOperands); odsState.addOperands(dataClauseOperands); ::llvm::copy(::llvm::ArrayRef({(ifCond ? 1 : 0), static_cast(asyncOperands.size()), static_cast(waitOperands.size()), static_cast(dataClauseOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (waitOperandsSegments) { odsState.getOrAddProperties().waitOperandsSegments = waitOperandsSegments; } if (waitOperandsDeviceType) { odsState.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceType; } if (hasWaitDevnum) { odsState.getOrAddProperties().hasWaitDevnum = hasWaitDevnum; } if (waitOnly) { odsState.getOrAddProperties().waitOnly = waitOnly; } if (ifPresent) { odsState.getOrAddProperties().ifPresent = ((ifPresent) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } UpdateOp UpdateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/bool ifPresent) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(ifCond), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(dataClauseOperands), std::forward(ifPresent)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UpdateOp UpdateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value ifCond, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::ValueRange waitOperands, /*optional*/::mlir::DenseI32ArrayAttr waitOperandsSegments, /*optional*/::mlir::ArrayAttr waitOperandsDeviceType, /*optional*/::mlir::ArrayAttr hasWaitDevnum, /*optional*/::mlir::ArrayAttr waitOnly, ::mlir::ValueRange dataClauseOperands, /*optional*/bool ifPresent) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(ifCond), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(waitOperands), std::forward(waitOperandsSegments), std::forward(waitOperandsDeviceType), std::forward(hasWaitDevnum), std::forward(waitOnly), std::forward(dataClauseOperands), std::forward(ifPresent)); } void UpdateOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); 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."); } } UpdateOp UpdateOp::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__; } UpdateOp UpdateOp::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 UpdateOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } UpdateOp UpdateOp::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__; } UpdateOp UpdateOp::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 UpdateOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_hasWaitDevnum = getProperties().hasWaitDevnum; (void)tblgen_hasWaitDevnum; auto tblgen_ifPresent = getProperties().ifPresent; (void)tblgen_ifPresent; auto tblgen_waitOnly = getProperties().waitOnly; (void)tblgen_waitOnly; auto tblgen_waitOperandsDeviceType = getProperties().waitOperandsDeviceType; (void)tblgen_waitOperandsDeviceType; auto tblgen_waitOperandsSegments = getProperties().waitOperandsSegments; (void)tblgen_waitOperandsSegments; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps9(*this, tblgen_waitOperandsSegments, "waitOperandsSegments"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_waitOperandsDeviceType, "waitOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps10(*this, tblgen_hasWaitDevnum, "hasWaitDevnum"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_waitOnly, "waitOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_ifPresent, "ifPresent"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); if (valueGroup0.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup0.size(); } for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps13(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult UpdateOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult UpdateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> waitOperandsOperands; ::llvm::SMLoc waitOperandsOperandsLoc; (void)waitOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> waitOperandsTypes; ::mlir::ArrayAttr waitOperandsDeviceTypeAttr; ::mlir::DenseI32ArrayAttr waitOperandsSegmentsAttr; ::mlir::ArrayAttr hasWaitDevnumAttr; ::mlir::ArrayAttr waitOnlyAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dataClauseOperandsOperands; ::llvm::SMLoc dataClauseOperandsOperandsLoc; (void)dataClauseOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> dataClauseOperandsTypes; bool ifClause = false; bool asyncClause = false; bool waitClause = false; bool dataOperandsClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("wait"))) { if (waitClause) { return parser.emitError(parser.getNameLoc()) << "`wait` clause can appear at most once in the expansion of the " "oilist directive"; } waitClause = true; { waitOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseWaitClause(parser, waitOperandsOperands, waitOperandsTypes, waitOperandsDeviceTypeAttr, waitOperandsSegmentsAttr, hasWaitDevnumAttr, waitOnlyAttr); if (odsResult) return ::mlir::failure(); if (waitOperandsDeviceTypeAttr) result.getOrAddProperties().waitOperandsDeviceType = waitOperandsDeviceTypeAttr; if (waitOperandsSegmentsAttr) result.getOrAddProperties().waitOperandsSegments = waitOperandsSegmentsAttr; if (hasWaitDevnumAttr) result.getOrAddProperties().hasWaitDevnum = hasWaitDevnumAttr; if (waitOnlyAttr) result.getOrAddProperties().waitOnly = waitOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("dataOperands"))) { if (dataOperandsClause) { return parser.emitError(parser.getNameLoc()) << "`dataOperands` clause can appear at most once in the expansion of the " "oilist directive"; } dataOperandsClause = true; if (parser.parseLParen()) return ::mlir::failure(); dataClauseOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(dataClauseOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(dataClauseOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } { 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(); } ::llvm::copy(::llvm::ArrayRef({static_cast(ifCondOperands.size()), static_cast(asyncOperandsOperands.size()), static_cast(waitOperandsOperands.size()), static_cast(dataClauseOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(waitOperandsOperands, waitOperandsTypes, waitOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(dataClauseOperandsOperands, dataClauseOperandsTypes, dataClauseOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void UpdateOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || getWaitOperands().size() || (getWaitOperandsDeviceTypeAttr()) || (getWaitOperandsSegmentsAttr()) || (getHasWaitDevnumAttr()) || (getWaitOnlyAttr())) { _odsPrinter << ' ' << "wait"; printWaitClause(_odsPrinter, *this, getWaitOperands(), getWaitOperands().getTypes(), getWaitOperandsDeviceTypeAttr(), getWaitOperandsSegmentsAttr(), getHasWaitDevnumAttr(), getWaitOnlyAttr()); } if (false || getDataClauseOperands().size()) { _odsPrinter << ' ' << "dataOperands"; _odsPrinter << "("; _odsPrinter << getDataClauseOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getDataClauseOperands().getTypes(); _odsPrinter << ")"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("waitOperandsDeviceType"); elidedAttrs.push_back("waitOperandsSegments"); elidedAttrs.push_back("hasWaitDevnum"); elidedAttrs.push_back("waitOnly"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getIfPresentAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("ifPresent"); } _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } void UpdateOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::acc::ConstructResource::get()); effects.emplace_back(::mlir::MemoryEffects::Read::get(), 0, false, ::mlir::acc::CurrentDeviceIdResource::get()); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::UpdateOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::UpdateOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::UseDeviceOp definitions //===----------------------------------------------------------------------===// namespace detail { UseDeviceOpGenericAdaptorBase::UseDeviceOpGenericAdaptorBase(UseDeviceOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair UseDeviceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::Type UseDeviceOpGenericAdaptorBase::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > UseDeviceOpGenericAdaptorBase::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > UseDeviceOpGenericAdaptorBase::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClauseAttr UseDeviceOpGenericAdaptorBase::getDataClauseAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseAttr>(getProperties().dataClause); return attr; } ::mlir::acc::DataClause UseDeviceOpGenericAdaptorBase::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } ::mlir::BoolAttr UseDeviceOpGenericAdaptorBase::getStructuredAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().structured); return attr; } bool UseDeviceOpGenericAdaptorBase::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } ::mlir::BoolAttr UseDeviceOpGenericAdaptorBase::getImplicitAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().implicit); return attr; } bool UseDeviceOpGenericAdaptorBase::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifierAttr UseDeviceOpGenericAdaptorBase::getModifiersAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::acc::DataClauseModifierAttr>(getProperties().modifiers); return attr; } ::mlir::acc::DataClauseModifier UseDeviceOpGenericAdaptorBase::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > UseDeviceOpGenericAdaptorBase::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > UseDeviceOpGenericAdaptorBase::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } } // namespace detail UseDeviceOpAdaptor::UseDeviceOpAdaptor(UseDeviceOp op) : UseDeviceOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult UseDeviceOpAdaptor::verify(::mlir::Location loc) { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitError(loc, "'acc.use_device' op requires attribute 'varType'"); if (tblgen_varType && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_varType))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_varType).getValue()))) && ((true)))) return emitError(loc, "'acc.use_device' op attribute 'varType' failed to satisfy constraint: any type attribute"); if (tblgen_asyncOperandsDeviceType && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOperandsDeviceType), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.use_device' op attribute 'asyncOperandsDeviceType' failed to satisfy constraint: device type array attribute"); if (tblgen_asyncOnly && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_asyncOnly))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_asyncOnly), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::acc::DeviceTypeAttr>(attr))); })))) return emitError(loc, "'acc.use_device' op attribute 'asyncOnly' failed to satisfy constraint: device type array attribute"); if (tblgen_dataClause && !((::llvm::isa<::mlir::acc::DataClauseAttr>(tblgen_dataClause)))) return emitError(loc, "'acc.use_device' op attribute 'dataClause' failed to satisfy constraint: data clauses supported by OpenACC"); if (tblgen_structured && !((::llvm::isa<::mlir::BoolAttr>(tblgen_structured)))) return emitError(loc, "'acc.use_device' op attribute 'structured' failed to satisfy constraint: bool attribute"); if (tblgen_implicit && !((::llvm::isa<::mlir::BoolAttr>(tblgen_implicit)))) return emitError(loc, "'acc.use_device' op attribute 'implicit' failed to satisfy constraint: bool attribute"); if (tblgen_modifiers && !((::llvm::isa<::mlir::acc::DataClauseModifierAttr>(tblgen_modifiers)))) return emitError(loc, "'acc.use_device' op attribute 'modifiers' failed to satisfy constraint: Captures data clause modifiers"); if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) return emitError(loc, "'acc.use_device' op attribute 'name' failed to satisfy constraint: string attribute"); if (tblgen_recipe && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_recipe)))) return emitError(loc, "'acc.use_device' op attribute 'recipe' failed to satisfy constraint: symbol reference attribute"); return ::mlir::success(); } std::pair UseDeviceOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange UseDeviceOp::getVarPtrPtrMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange UseDeviceOp::getBoundsMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange UseDeviceOp::getAsyncOperandsMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult UseDeviceOp::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.asyncOnly; auto attr = dict.get("asyncOnly"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOnly` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.asyncOperandsDeviceType; auto attr = dict.get("asyncOperandsDeviceType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `asyncOperandsDeviceType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.dataClause; auto attr = dict.get("dataClause"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `dataClause` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.implicit; auto attr = dict.get("implicit"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `implicit` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.modifiers; auto attr = dict.get("modifiers"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `modifiers` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.name; auto attr = dict.get("name"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `name` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.recipe; auto attr = dict.get("recipe"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `recipe` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.structured; auto attr = dict.get("structured"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `structured` in property conversion: " << attr; return ::mlir::failure(); } } } { auto &propStorage = prop.varType; auto attr = dict.get("varType"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `varType` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute UseDeviceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.asyncOnly; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOnly", propStorage)); } { const auto &propStorage = prop.asyncOperandsDeviceType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("asyncOperandsDeviceType", propStorage)); } { const auto &propStorage = prop.dataClause; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("dataClause", propStorage)); } { const auto &propStorage = prop.implicit; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("implicit", propStorage)); } { const auto &propStorage = prop.modifiers; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("modifiers", propStorage)); } { const auto &propStorage = prop.name; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("name", propStorage)); } { const auto &propStorage = prop.recipe; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("recipe", propStorage)); } { const auto &propStorage = prop.structured; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("structured", propStorage)); } { const auto &propStorage = prop.varType; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("varType", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code UseDeviceOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.asyncOnly.getAsOpaquePointer()), llvm::hash_value(prop.asyncOperandsDeviceType.getAsOpaquePointer()), llvm::hash_value(prop.dataClause.getAsOpaquePointer()), llvm::hash_value(prop.implicit.getAsOpaquePointer()), llvm::hash_value(prop.modifiers.getAsOpaquePointer()), llvm::hash_value(prop.name.getAsOpaquePointer()), llvm::hash_value(prop.recipe.getAsOpaquePointer()), llvm::hash_value(prop.structured.getAsOpaquePointer()), llvm::hash_value(prop.varType.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional UseDeviceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "asyncOnly") return prop.asyncOnly; if (name == "asyncOperandsDeviceType") return prop.asyncOperandsDeviceType; if (name == "dataClause") return prop.dataClause; if (name == "implicit") return prop.implicit; if (name == "modifiers") return prop.modifiers; if (name == "name") return prop.name; if (name == "recipe") return prop.recipe; if (name == "structured") return prop.structured; if (name == "varType") return prop.varType; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void UseDeviceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "asyncOnly") { prop.asyncOnly = ::llvm::dyn_cast_or_null>(value); return; } if (name == "asyncOperandsDeviceType") { prop.asyncOperandsDeviceType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "dataClause") { prop.dataClause = ::llvm::dyn_cast_or_null>(value); return; } if (name == "implicit") { prop.implicit = ::llvm::dyn_cast_or_null>(value); return; } if (name == "modifiers") { prop.modifiers = ::llvm::dyn_cast_or_null>(value); return; } if (name == "name") { prop.name = ::llvm::dyn_cast_or_null>(value); return; } if (name == "recipe") { prop.recipe = ::llvm::dyn_cast_or_null>(value); return; } if (name == "structured") { prop.structured = ::llvm::dyn_cast_or_null>(value); return; } if (name == "varType") { prop.varType = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void UseDeviceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.asyncOnly) attrs.append("asyncOnly", prop.asyncOnly); if (prop.asyncOperandsDeviceType) attrs.append("asyncOperandsDeviceType", prop.asyncOperandsDeviceType); if (prop.dataClause) attrs.append("dataClause", prop.dataClause); if (prop.implicit) attrs.append("implicit", prop.implicit); if (prop.modifiers) attrs.append("modifiers", prop.modifiers); if (prop.name) attrs.append("name", prop.name); if (prop.recipe) attrs.append("recipe", prop.recipe); if (prop.structured) attrs.append("structured", prop.structured); if (prop.varType) attrs.append("varType", prop.varType); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult UseDeviceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncOnlyAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOnly", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getAsyncOperandsDeviceTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(attr, "asyncOperandsDeviceType", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getDataClauseAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(attr, "dataClause", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getImplicitAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "implicit", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getModifiersAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(attr, "modifiers", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(attr, "name", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getRecipeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(attr, "recipe", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getStructuredAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(attr, "structured", emitError))) return ::mlir::failure(); } { ::mlir::Attribute attr = attrs.get(getVarTypeAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(attr, "varType", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult UseDeviceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOnly))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.asyncOperandsDeviceType))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.dataClause))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.implicit))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.modifiers))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.name))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } if (::mlir::failed(reader.readOptionalAttribute(prop.recipe))) return ::mlir::failure(); if (::mlir::failed(reader.readOptionalAttribute(prop.structured))) return ::mlir::failure(); if (::mlir::failed(reader.readAttribute(prop.varType))) return ::mlir::failure(); { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void UseDeviceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.asyncOnly); writer.writeOptionalAttribute(prop.asyncOperandsDeviceType); writer.writeOptionalAttribute(prop.dataClause); writer.writeOptionalAttribute(prop.implicit); writer.writeOptionalAttribute(prop.modifiers); writer.writeOptionalAttribute(prop.name); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } writer.writeOptionalAttribute(prop.recipe); writer.writeOptionalAttribute(prop.structured); writer.writeAttribute(prop.varType); { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } ::mlir::Type UseDeviceOp::getVarType() { auto attr = getVarTypeAttr(); return ::llvm::cast<::mlir::Type>(attr.getValue()); } ::std::optional< ::mlir::ArrayAttr > UseDeviceOp::getAsyncOperandsDeviceType() { auto attr = getAsyncOperandsDeviceTypeAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::std::optional< ::mlir::ArrayAttr > UseDeviceOp::getAsyncOnly() { auto attr = getAsyncOnlyAttr(); return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); } ::mlir::acc::DataClause UseDeviceOp::getDataClause() { auto attr = getDataClauseAttr(); return attr.getValue(); } bool UseDeviceOp::getStructured() { auto attr = getStructuredAttr(); return attr.getValue(); } bool UseDeviceOp::getImplicit() { auto attr = getImplicitAttr(); return attr.getValue(); } ::mlir::acc::DataClauseModifier UseDeviceOp::getModifiers() { auto attr = getModifiersAttr(); return attr.getValue(); } ::std::optional< ::llvm::StringRef > UseDeviceOp::getName() { auto attr = getNameAttr(); return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); } ::std::optional< ::mlir::SymbolRefAttr > UseDeviceOp::getRecipe() { auto attr = getRecipeAttr(); return attr ? ::std::optional< ::mlir::SymbolRefAttr >(attr) : (::std::nullopt); } void UseDeviceOp::setVarType(::mlir::Type attrValue) { getProperties().varType = ::mlir::TypeAttr::get(attrValue); } void UseDeviceOp::setDataClause(::mlir::acc::DataClause attrValue) { getProperties().dataClause = ::mlir::acc::DataClauseAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void UseDeviceOp::setStructured(bool attrValue) { getProperties().structured = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void UseDeviceOp::setImplicit(bool attrValue) { getProperties().implicit = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); } void UseDeviceOp::setModifiers(::mlir::acc::DataClauseModifier attrValue) { getProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); } void UseDeviceOp::setName(::std::optional<::llvm::StringRef> attrValue) { auto &odsProp = getProperties().name; if (attrValue) odsProp = ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue); else odsProp = nullptr; } void UseDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/nullptr, /*recipe=*/nullptr); } UseDeviceOp UseDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UseDeviceOp UseDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(bounds)); } void UseDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { auto ptrLikeTy = ::mlir::dyn_cast<::mlir::acc::PointerLikeType>( var.getType()); build(odsBuilder, odsState, var.getType(), var, /*varType=*/ptrLikeTy ? ::mlir::TypeAttr::get(ptrLikeTy.getElementType()) : ::mlir::TypeAttr::get(var.getType()), /*varPtrPtr=*/{}, bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr, /*asyncOnly=*/nullptr, /*dataClause=*/nullptr, /*structured=*/odsBuilder.getBoolAttr(structured), /*implicit=*/odsBuilder.getBoolAttr(implicit), /*modifiers=*/nullptr, /*name=*/odsBuilder.getStringAttr(name), /*recipe=*/nullptr); } UseDeviceOp UseDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UseDeviceOp UseDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value var, bool structured, bool implicit, const ::llvm::Twine &name, ::mlir::ValueRange bounds) { return create(builder, builder.getLoc(), std::forward(var), std::forward(structured), std::forward(implicit), std::forward(name), std::forward(bounds)); } void UseDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { // Builder provided to ease transition for new data clause modifiers operand. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, ::mlir::acc::DataClauseModifier::none, name); } UseDeviceOp UseDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UseDeviceOp UseDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(name)); } void UseDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { // Builder provided to simplify building after recipe operand was added. build(odsBuilder, odsState, accVarType, var, varType, varPtrPtr, bounds, asyncOperands, asyncOperandsDeviceType, asyncOnly, dataClause, structured, implicit, modifiers, name, /*recipe=*/nullptr); } UseDeviceOp UseDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UseDeviceOp UseDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVarType, ::mlir::Value var, ::mlir::Type varType, ::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, ::mlir::ArrayAttr asyncOperandsDeviceType, ::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, ::mlir::StringAttr name) { return create(builder, builder.getLoc(), std::forward(accVarType), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name)); } void UseDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } UseDeviceOp UseDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UseDeviceOp UseDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void UseDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = varType; if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } if (dataClause) { odsState.getOrAddProperties().dataClause = dataClause; } if (structured) { odsState.getOrAddProperties().structured = structured; } if (implicit) { odsState.getOrAddProperties().implicit = implicit; } if (modifiers) { odsState.getOrAddProperties().modifiers = modifiers; } if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } UseDeviceOp UseDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UseDeviceOp UseDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::TypeAttr varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClauseAttr dataClause, ::mlir::BoolAttr structured, ::mlir::BoolAttr implicit, ::mlir::acc::DataClauseModifierAttr modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void UseDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } odsState.addTypes(accVar); } UseDeviceOp UseDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UseDeviceOp UseDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type accVar, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(accVar), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void UseDeviceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { odsState.addOperands(var); if (varPtrPtr) odsState.addOperands(varPtrPtr); odsState.addOperands(bounds); odsState.addOperands(asyncOperands); ::llvm::copy(::llvm::ArrayRef({1, (varPtrPtr ? 1 : 0), static_cast(bounds.size()), static_cast(asyncOperands.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); odsState.getOrAddProperties().varType = ::mlir::TypeAttr::get(varType); if (asyncOperandsDeviceType) { odsState.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceType; } if (asyncOnly) { odsState.getOrAddProperties().asyncOnly = asyncOnly; } odsState.getOrAddProperties().dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), dataClause); odsState.getOrAddProperties().structured = odsBuilder.getBoolAttr(structured); odsState.getOrAddProperties().implicit = odsBuilder.getBoolAttr(implicit); odsState.getOrAddProperties().modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), modifiers); if (name) { odsState.getOrAddProperties().name = name; } if (recipe) { odsState.getOrAddProperties().recipe = recipe; } assert(resultTypes.size() == 1u && "mismatched number of results"); odsState.addTypes(resultTypes); } UseDeviceOp UseDeviceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } UseDeviceOp UseDeviceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value var, ::mlir::Type varType, /*optional*/::mlir::Value varPtrPtr, ::mlir::ValueRange bounds, ::mlir::ValueRange asyncOperands, /*optional*/::mlir::ArrayAttr asyncOperandsDeviceType, /*optional*/::mlir::ArrayAttr asyncOnly, ::mlir::acc::DataClause dataClause, bool structured, bool implicit, ::mlir::acc::DataClauseModifier modifiers, /*optional*/::mlir::StringAttr name, /*optional*/::mlir::SymbolRefAttr recipe) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(var), std::forward(varType), std::forward(varPtrPtr), std::forward(bounds), std::forward(asyncOperands), std::forward(asyncOperandsDeviceType), std::forward(asyncOnly), std::forward(dataClause), std::forward(structured), std::forward(implicit), std::forward(modifiers), std::forward(name), std::forward(recipe)); } void UseDeviceOp::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."); } } UseDeviceOp UseDeviceOp::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__; } UseDeviceOp UseDeviceOp::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 UseDeviceOp::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); } UseDeviceOp UseDeviceOp::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__; } UseDeviceOp UseDeviceOp::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 UseDeviceOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { ::mlir::Builder odsBuilder(opName.getContext()); if (!properties.dataClause) properties.dataClause = ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_use_device); if (!properties.structured) properties.structured = odsBuilder.getBoolAttr(true); if (!properties.implicit) properties.implicit = odsBuilder.getBoolAttr(false); if (!properties.modifiers) properties.modifiers = ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none); } ::llvm::LogicalResult UseDeviceOp::verifyInvariantsImpl() { auto tblgen_asyncOnly = getProperties().asyncOnly; (void)tblgen_asyncOnly; auto tblgen_asyncOperandsDeviceType = getProperties().asyncOperandsDeviceType; (void)tblgen_asyncOperandsDeviceType; auto tblgen_dataClause = getProperties().dataClause; (void)tblgen_dataClause; auto tblgen_implicit = getProperties().implicit; (void)tblgen_implicit; auto tblgen_modifiers = getProperties().modifiers; (void)tblgen_modifiers; auto tblgen_name = getProperties().name; (void)tblgen_name; auto tblgen_recipe = getProperties().recipe; (void)tblgen_recipe; auto tblgen_structured = getProperties().structured; (void)tblgen_structured; auto tblgen_varType = getProperties().varType; (void)tblgen_varType; if (!tblgen_varType) return emitOpError("requires attribute 'varType'"); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps1(*this, tblgen_varType, "varType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOperandsDeviceType, "asyncOperandsDeviceType"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps2(*this, tblgen_asyncOnly, "asyncOnly"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps3(*this, tblgen_dataClause, "dataClause"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_structured, "structured"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps4(*this, tblgen_implicit, "implicit"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps5(*this, tblgen_modifiers, "modifiers"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps6(*this, tblgen_name, "name"))) return ::mlir::failure(); if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps7(*this, tblgen_recipe, "recipe"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps4(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps5(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps6(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*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_OpenACCOps4(*this, v.getType(), "result", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult UseDeviceOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult UseDeviceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::mlir::OpAsmParser::UnresolvedOperand varRawOperand{}; ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> varOperands(&varRawOperand, 1); ::llvm::SMLoc varOperandsLoc; (void)varOperandsLoc; ::mlir::Type varRawType{}; ::llvm::ArrayRef<::mlir::Type> varTypes(&varRawType, 1); ::mlir::TypeAttr varTypeAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> varPtrPtrOperands; ::llvm::SMLoc varPtrPtrOperandsLoc; (void)varPtrPtrOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> varPtrPtrTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> boundsOperands; ::llvm::SMLoc boundsOperandsLoc; (void)boundsOperandsLoc; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandsOperands; ::llvm::SMLoc asyncOperandsOperandsLoc; (void)asyncOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandsTypes; ::mlir::ArrayAttr asyncOperandsDeviceTypeAttr; ::mlir::ArrayAttr asyncOnlyAttr; ::mlir::SymbolRefAttr recipeAttr; ::mlir::Type accVarRawType{}; ::llvm::ArrayRef<::mlir::Type> accVarTypes(&accVarRawType, 1); { varOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseVar(parser, varRawOperand); if (odsResult) return ::mlir::failure(); } if (parser.parseColon()) return ::mlir::failure(); { auto odsResult = parseVarPtrType(parser, varRawType, varTypeAttr); if (odsResult) return ::mlir::failure(); result.getOrAddProperties().varType = varTypeAttr; } bool varPtrPtrClause = false; bool boundsClause = false; bool asyncClause = false; bool recipeClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("varPtrPtr"))) { if (varPtrPtrClause) { return parser.emitError(parser.getNameLoc()) << "`varPtrPtr` clause can appear at most once in the expansion of the " "oilist directive"; } varPtrPtrClause = true; if (parser.parseLParen()) return ::mlir::failure(); { varPtrPtrOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); varPtrPtrTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("bounds"))) { if (boundsClause) { return parser.emitError(parser.getNameLoc()) << "`bounds` clause can appear at most once in the expansion of the " "oilist directive"; } boundsClause = true; if (parser.parseLParen()) return ::mlir::failure(); boundsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(boundsOperands)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandsOperandsLoc = parser.getCurrentLocation(); auto odsResult = parseDeviceTypeOperandsWithKeywordOnly(parser, asyncOperandsOperands, asyncOperandsTypes, asyncOperandsDeviceTypeAttr, asyncOnlyAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandsDeviceTypeAttr) result.getOrAddProperties().asyncOperandsDeviceType = asyncOperandsDeviceTypeAttr; if (asyncOnlyAttr) result.getOrAddProperties().asyncOnly = asyncOnlyAttr; } } else if (succeeded(parser.parseOptionalKeyword("recipe"))) { if (recipeClause) { return parser.emitError(parser.getNameLoc()) << "`recipe` clause can appear at most once in the expansion of the " "oilist directive"; } recipeClause = true; if (parser.parseLParen()) return ::mlir::failure(); { auto odsResult = parseRecipeSym(parser, recipeAttr); if (odsResult) return ::mlir::failure(); if (recipeAttr) result.getOrAddProperties().recipe = recipeAttr; } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } if (parser.parseArrow()) return ::mlir::failure(); { ::mlir::Type type; if (parser.parseCustomTypeWithFallback(type)) return ::mlir::failure(); accVarRawType = type; } { auto loc = parser.getCurrentLocation();(void)loc; if (parser.parseOptionalAttrDict(result.attributes)) return ::mlir::failure(); if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; }))) return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef({1, static_cast(varPtrPtrOperands.size()), static_cast(boundsOperands.size()), static_cast(asyncOperandsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::acc::DataBoundsType>(); result.addTypes(accVarTypes); if (parser.resolveOperands(varOperands, varTypes, varOperandsLoc, result.operands)) return ::mlir::failure(); if (!varPtrPtrOperands.empty()) { if (parser.resolveOperands(varPtrPtrOperands, varPtrPtrTypes, varPtrPtrOperandsLoc, result.operands)) return ::mlir::failure(); } if (parser.resolveOperands(boundsOperands, odsBuildableType0, boundsOperandsLoc, result.operands)) return ::mlir::failure(); if (parser.resolveOperands(asyncOperandsOperands, asyncOperandsTypes, asyncOperandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void UseDeviceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { _odsPrinter << ' '; printVar(_odsPrinter, *this, getVar()); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; printVarPtrType(_odsPrinter, *this, getVar().getType(), getVarTypeAttr()); if (false || getVarPtrPtr()) { _odsPrinter << ' ' << "varPtrPtr"; _odsPrinter << "("; if (::mlir::Value value = getVarPtrPtr()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getVarPtrPtr() ? ::llvm::ArrayRef<::mlir::Type>(getVarPtrPtr().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getBounds().size()) { _odsPrinter << ' ' << "bounds"; _odsPrinter << "("; _odsPrinter << getBounds(); _odsPrinter << ")"; } if (false || getAsyncOperands().size() || (getAsyncOperandsDeviceTypeAttr()) || (getAsyncOnlyAttr())) { _odsPrinter << ' ' << "async"; printDeviceTypeOperandsWithKeywordOnly(_odsPrinter, *this, getAsyncOperands(), getAsyncOperands().getTypes(), getAsyncOperandsDeviceTypeAttr(), getAsyncOnlyAttr()); } if (false || (getRecipeAttr())) { _odsPrinter << ' ' << "recipe"; _odsPrinter << "("; printRecipeSym(_odsPrinter, *this, getRecipeAttr()); _odsPrinter << ")"; } _odsPrinter << ' ' << "->"; _odsPrinter << ' '; { auto type = getAccVar().getType(); if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) _odsPrinter.printStrippedAttrOrType(validType); else _odsPrinter << type; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("varType"); elidedAttrs.push_back("asyncOperandsDeviceType"); elidedAttrs.push_back("asyncOnly"); elidedAttrs.push_back("recipe"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getDataClauseAttr(); if(attr && (attr == ::mlir::acc::DataClauseAttr::get(odsBuilder.getContext(), mlir::acc::DataClause::acc_use_device))) elidedAttrs.push_back("dataClause"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getStructuredAttr(); if(attr && (attr == odsBuilder.getBoolAttr(true))) elidedAttrs.push_back("structured"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getImplicitAttr(); if(attr && (attr == odsBuilder.getBoolAttr(false))) elidedAttrs.push_back("implicit"); } { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getModifiersAttr(); if(attr && (attr == ::mlir::acc::DataClauseModifierAttr::get(odsBuilder.getContext(), mlir::acc::DataClauseModifier::none))) elidedAttrs.push_back("modifiers"); } _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::UseDeviceOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::UseDeviceOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::WaitOp definitions //===----------------------------------------------------------------------===// namespace detail { WaitOpGenericAdaptorBase::WaitOpGenericAdaptorBase(WaitOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair WaitOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::UnitAttr WaitOpGenericAdaptorBase::getAsyncAttr() { auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().async); if (!attr) attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); return attr; } bool WaitOpGenericAdaptorBase::getAsync() { auto attr = getAsyncAttr(); if (!attr) return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } } // namespace detail WaitOpAdaptor::WaitOpAdaptor(WaitOp op) : WaitOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult WaitOpAdaptor::verify(::mlir::Location loc) { auto tblgen_async = getProperties().async; (void)tblgen_async; if (tblgen_async && !((::llvm::isa<::mlir::UnitAttr>(tblgen_async)))) return emitError(loc, "'acc.wait' op attribute 'async' failed to satisfy constraint: unit attribute"); return ::mlir::success(); } std::pair WaitOp::getODSOperandIndexAndLength(unsigned index) { ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; unsigned start = 0; for (unsigned i = 0; i < index; ++i) start += sizeAttr[i]; return {start, sizeAttr[index]}; } ::mlir::MutableOperandRange WaitOp::getWaitOperandsMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange WaitOp::getAsyncOperandMutable() { auto range = getODSOperandIndexAndLength(1); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange WaitOp::getWaitDevnumMutable() { auto range = getODSOperandIndexAndLength(2); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::mlir::MutableOperandRange WaitOp::getIfCondMutable() { auto range = getODSOperandIndexAndLength(3); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); return mutableRange; } ::llvm::LogicalResult WaitOp::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.async; auto attr = dict.get("async"); if (attr) { auto convertedAttr = ::llvm::dyn_cast>(attr); if (convertedAttr) { propStorage = convertedAttr; } else { emitError() << "Invalid attribute `async` in property conversion: " << attr; return ::mlir::failure(); } } } { auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult { return convertFromAttribute(propStorage, propAttr, emitError); }; auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; ; if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() { return emitError() << "for `operandSegmentSizes`: "; }))) return ::mlir::failure(); } return ::mlir::success(); } ::mlir::Attribute WaitOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { ::mlir::SmallVector<::mlir::NamedAttribute> attrs; ::mlir::Builder odsBuilder{ctx}; { const auto &propStorage = prop.async; if (propStorage) attrs.push_back(odsBuilder.getNamedAttr("async", propStorage)); } { const auto &propStorage = prop.operandSegmentSizes; auto attr = [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage); }(); attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr)); } if (!attrs.empty()) return odsBuilder.getDictionaryAttr(attrs); return {}; } llvm::hash_code WaitOp::computePropertiesHash(const Properties &prop) { auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code { using ::llvm::hash_value; return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; }; using llvm::hash_value; return llvm::hash_combine( llvm::hash_value(prop.async.getAsOpaquePointer()), hash_operandSegmentSizes_(prop.operandSegmentSizes)); } std::optional WaitOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { if (name == "async") return prop.async; if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }(); return std::nullopt; } void WaitOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { if (name == "async") { prop.async = ::llvm::dyn_cast_or_null>(value); return; } if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); if (!arrAttr) return; if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) return; llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); return; } } void WaitOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { if (prop.async) attrs.append("async", prop.async); attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }()); } ::llvm::LogicalResult WaitOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { { ::mlir::Attribute attr = attrs.get(getAsyncAttrName(opName)); if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(attr, "async", emitError))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult WaitOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { auto &prop = state.getOrAddProperties(); (void)prop; if (::mlir::failed(reader.readOptionalAttribute(prop.async))) return ::mlir::failure(); if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; ::mlir::DenseI32ArrayAttr attr; if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { reader.emitError("size mismatch for operand/result_segment_size"); return ::mlir::failure(); } ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); } { auto &propStorage = prop.operandSegmentSizes; auto readProp = [&]() { if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); ; return ::mlir::success(); }; if (::mlir::failed(readProp())) return ::mlir::failure(); } return ::mlir::success(); } void WaitOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { auto &prop = getProperties(); (void)prop; writer.writeOptionalAttribute(prop.async); if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { auto &propStorage = prop.operandSegmentSizes; writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage)); } { auto &propStorage = prop.operandSegmentSizes; if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6) writer.writeSparseArray(::llvm::ArrayRef(propStorage)); ; } } bool WaitOp::getAsync() { auto attr = getAsyncAttr(); if (!attr) return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; return attr != nullptr; } void WaitOp::setAsync(bool attrValue) { auto &odsProp = getProperties().async; if (attrValue) odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); else odsProp = nullptr; } void WaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange waitOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::Value waitDevnum, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value ifCond) { odsState.addOperands(waitOperands); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); if (ifCond) odsState.addOperands(ifCond); ::llvm::copy(::llvm::ArrayRef({static_cast(waitOperands.size()), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), (ifCond ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (async) { odsState.getOrAddProperties().async = async; } } WaitOp WaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange waitOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::Value waitDevnum, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(waitOperands), std::forward(asyncOperand), std::forward(waitDevnum), std::forward(async), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WaitOp WaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange waitOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::Value waitDevnum, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(waitOperands), std::forward(asyncOperand), std::forward(waitDevnum), std::forward(async), std::forward(ifCond)); } void WaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange waitOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::Value waitDevnum, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value ifCond) { odsState.addOperands(waitOperands); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); if (ifCond) odsState.addOperands(ifCond); ::llvm::copy(::llvm::ArrayRef({static_cast(waitOperands.size()), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), (ifCond ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (async) { odsState.getOrAddProperties().async = async; } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } WaitOp WaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange waitOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::Value waitDevnum, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(waitOperands), std::forward(asyncOperand), std::forward(waitDevnum), std::forward(async), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WaitOp WaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange waitOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::Value waitDevnum, /*optional*/::mlir::UnitAttr async, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(waitOperands), std::forward(asyncOperand), std::forward(waitDevnum), std::forward(async), std::forward(ifCond)); } void WaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange waitOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::Value waitDevnum, /*optional*/bool async, /*optional*/::mlir::Value ifCond) { odsState.addOperands(waitOperands); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); if (ifCond) odsState.addOperands(ifCond); ::llvm::copy(::llvm::ArrayRef({static_cast(waitOperands.size()), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), (ifCond ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (async) { odsState.getOrAddProperties().async = ((async) ? odsBuilder.getUnitAttr() : nullptr); } } WaitOp WaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange waitOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::Value waitDevnum, /*optional*/bool async, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(waitOperands), std::forward(asyncOperand), std::forward(waitDevnum), std::forward(async), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WaitOp WaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange waitOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::Value waitDevnum, /*optional*/bool async, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(waitOperands), std::forward(asyncOperand), std::forward(waitDevnum), std::forward(async), std::forward(ifCond)); } void WaitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange waitOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::Value waitDevnum, /*optional*/bool async, /*optional*/::mlir::Value ifCond) { odsState.addOperands(waitOperands); if (asyncOperand) odsState.addOperands(asyncOperand); if (waitDevnum) odsState.addOperands(waitDevnum); if (ifCond) odsState.addOperands(ifCond); ::llvm::copy(::llvm::ArrayRef({static_cast(waitOperands.size()), (asyncOperand ? 1 : 0), (waitDevnum ? 1 : 0), (ifCond ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); if (async) { odsState.getOrAddProperties().async = ((async) ? odsBuilder.getUnitAttr() : nullptr); } assert(resultTypes.size() == 0u && "mismatched number of results"); odsState.addTypes(resultTypes); } WaitOp WaitOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange waitOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::Value waitDevnum, /*optional*/bool async, /*optional*/::mlir::Value ifCond) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(resultTypes), std::forward(waitOperands), std::forward(asyncOperand), std::forward(waitDevnum), std::forward(async), std::forward(ifCond)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } WaitOp WaitOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange waitOperands, /*optional*/::mlir::Value asyncOperand, /*optional*/::mlir::Value waitDevnum, /*optional*/bool async, /*optional*/::mlir::Value ifCond) { return create(builder, builder.getLoc(), std::forward(resultTypes), std::forward(waitOperands), std::forward(asyncOperand), std::forward(waitDevnum), std::forward(async), std::forward(ifCond)); } void WaitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); 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."); } } WaitOp WaitOp::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__; } WaitOp WaitOp::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 WaitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } WaitOp WaitOp::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__; } WaitOp WaitOp::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 WaitOp::verifyInvariantsImpl() { auto tblgen_async = getProperties().async; (void)tblgen_async; if (::mlir::failed(__mlir_ods_local_attr_constraint_OpenACCOps12(*this, tblgen_async, "async"))) return ::mlir::failure(); { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps7(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup1 = getODSOperands(1); if (valueGroup1.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup1.size(); } for (auto v : valueGroup1) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup2 = getODSOperands(2); if (valueGroup2.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup2.size(); } for (auto v : valueGroup2) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps11(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } auto valueGroup3 = getODSOperands(3); if (valueGroup3.size() > 1) { return emitOpError("operand group starting at #") << index << " requires 0 or 1 element, but found " << valueGroup3.size(); } for (auto v : valueGroup3) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps1(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult WaitOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } ::mlir::ParseResult WaitOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> waitOperandsOperands; ::llvm::SMLoc waitOperandsOperandsLoc; (void)waitOperandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> waitOperandsTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> asyncOperandOperands; ::llvm::SMLoc asyncOperandOperandsLoc; (void)asyncOperandOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> asyncOperandTypes; ::mlir::UnitAttr asyncAttr; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> waitDevnumOperands; ::llvm::SMLoc waitDevnumOperandsLoc; (void)waitDevnumOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> waitDevnumTypes; ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ifCondOperands; ::llvm::SMLoc ifCondOperandsLoc; (void)ifCondOperandsLoc; if (::mlir::succeeded(parser.parseOptionalLParen())) { waitOperandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(waitOperandsOperands)) return ::mlir::failure(); if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(waitOperandsTypes)) return ::mlir::failure(); if (parser.parseRParen()) return ::mlir::failure(); } bool asyncClause = false; bool wait_devnumClause = false; bool ifClause = false; while(true) { if (succeeded(parser.parseOptionalKeyword("async"))) { if (asyncClause) { return parser.emitError(parser.getNameLoc()) << "`async` clause can appear at most once in the expansion of the " "oilist directive"; } asyncClause = true; { asyncOperandOperandsLoc = parser.getCurrentLocation(); ::std::optional<::mlir::OpAsmParser::UnresolvedOperand> asyncOperandOperand; ::mlir::Type asyncOperandType; auto odsResult = parseOperandWithKeywordOnly(parser, asyncOperandOperand, asyncOperandType, asyncAttr); if (odsResult) return ::mlir::failure(); if (asyncOperandOperand.has_value()) asyncOperandOperands.push_back(*asyncOperandOperand); if (asyncOperandType) asyncOperandTypes.push_back(asyncOperandType); if (asyncAttr) result.getOrAddProperties().async = asyncAttr; } } else if (succeeded(parser.parseOptionalKeyword("wait_devnum"))) { if (wait_devnumClause) { return parser.emitError(parser.getNameLoc()) << "`wait_devnum` clause can appear at most once in the expansion of the " "oilist directive"; } wait_devnumClause = true; if (parser.parseLParen()) return ::mlir::failure(); { waitDevnumOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); waitDevnumOperands.push_back(operand); } } if (parser.parseColon()) return ::mlir::failure(); { ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); waitDevnumTypes.push_back(optionalType); } } if (parser.parseRParen()) return ::mlir::failure(); } else if (succeeded(parser.parseOptionalKeyword("if"))) { if (ifClause) { return parser.emitError(parser.getNameLoc()) << "`if` clause can appear at most once in the expansion of the " "oilist directive"; } ifClause = true; if (parser.parseLParen()) return ::mlir::failure(); { ifCondOperandsLoc = parser.getCurrentLocation(); ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); ifCondOperands.push_back(operand); } } if (parser.parseRParen()) return ::mlir::failure(); } else { break; } } { 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(); } ::llvm::copy(::llvm::ArrayRef({static_cast(waitOperandsOperands.size()), static_cast(asyncOperandOperands.size()), static_cast(waitDevnumOperands.size()), static_cast(ifCondOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); if (parser.resolveOperands(waitOperandsOperands, waitOperandsTypes, waitOperandsOperandsLoc, result.operands)) return ::mlir::failure(); if (!asyncOperandOperands.empty()) { if (parser.resolveOperands(asyncOperandOperands, asyncOperandTypes, asyncOperandOperandsLoc, result.operands)) return ::mlir::failure(); } if (!waitDevnumOperands.empty()) { if (parser.resolveOperands(waitDevnumOperands, waitDevnumTypes, waitDevnumOperandsLoc, result.operands)) return ::mlir::failure(); } if (!ifCondOperands.empty()) { if (parser.resolveOperands(ifCondOperands, odsBuildableType0, ifCondOperandsLoc, result.operands)) return ::mlir::failure(); } return ::mlir::success(); } void WaitOp::print(::mlir::OpAsmPrinter &_odsPrinter) { if (!getWaitOperands().empty()) { _odsPrinter << "("; _odsPrinter << getWaitOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getWaitOperands().getTypes(); _odsPrinter << ")"; } if (false || getAsyncOperand() || ((getAsyncAttr() && getAsyncAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr)))) { _odsPrinter << ' ' << "async"; printOperandWithKeywordOnly(_odsPrinter, *this, getAsyncOperand(), (getAsyncOperand() ? getAsyncOperand().getType() : ::mlir::Type()), getAsyncAttr()); } if (false || getWaitDevnum()) { _odsPrinter << ' ' << "wait_devnum"; _odsPrinter << "("; if (::mlir::Value value = getWaitDevnum()) _odsPrinter << value; _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << (getWaitDevnum() ? ::llvm::ArrayRef<::mlir::Type>(getWaitDevnum().getType()) : ::llvm::ArrayRef<::mlir::Type>()); _odsPrinter << ")"; } if (false || getIfCond()) { _odsPrinter << ' ' << "if"; _odsPrinter << "("; if (::mlir::Value value = getIfCond()) _odsPrinter << value; _odsPrinter << ")"; } ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; elidedAttrs.push_back("operandSegmentSizes"); elidedAttrs.push_back("async"); { ::mlir::Builder odsBuilder(getContext()); ::mlir::Attribute attr = getAsyncAttr(); if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) elidedAttrs.push_back("async"); } _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::WaitOp) MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::detail::WaitOpGenericAdaptorBase::Properties) namespace mlir::acc { //===----------------------------------------------------------------------===// // ::mlir::acc::YieldOp definitions //===----------------------------------------------------------------------===// namespace detail { YieldOpGenericAdaptorBase::YieldOpGenericAdaptorBase(YieldOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} std::pair YieldOpGenericAdaptorBase::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 YieldOpAdaptor::YieldOpAdaptor(YieldOp op) : YieldOpGenericAdaptor(op->getOperands(), op) {} ::llvm::LogicalResult YieldOpAdaptor::verify(::mlir::Location loc) { return ::mlir::success(); } std::pair YieldOp::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 YieldOp::getOperandsMutable() { auto range = getODSOperandIndexAndLength(0); auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); return mutableRange; } ::llvm::LogicalResult YieldOp::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 YieldOp::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 YieldOp::computePropertiesHash(const Properties &prop) { using llvm::hash_value; return llvm::hash_combine(); } std::optional YieldOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { return std::nullopt; } void YieldOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { } void YieldOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { } ::llvm::LogicalResult YieldOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { return ::mlir::success(); } void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { /* nothing to do */ } YieldOp YieldOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } YieldOp YieldOp::create(::mlir::ImplicitLocOpBuilder &builder) { return create(builder, builder.getLoc()); } void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands) { odsState.addOperands(operands); } YieldOp YieldOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands) { ::mlir::OperationState __state__(location, getOperationName()); build(builder, __state__, std::forward(operands)); auto __res__ = ::llvm::dyn_cast(builder.create(__state__)); assert(__res__ && "builder didn't return the right type"); return __res__; } YieldOp YieldOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands) { return create(builder, builder.getLoc(), std::forward(operands)); } void YieldOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { odsState.addOperands(operands); odsState.addAttributes(attributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } YieldOp YieldOp::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__; } YieldOp YieldOp::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 YieldOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { odsState.addOperands(operands); odsState.useProperties(const_cast(properties)); odsState.addAttributes(discardableAttributes); assert(resultTypes.size() == 0u && "mismatched number of return types"); odsState.addTypes(resultTypes); } YieldOp YieldOp::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__; } YieldOp YieldOp::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 YieldOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; auto valueGroup0 = getODSOperands(0); for (auto v : valueGroup0) { if (::mlir::failed(__mlir_ods_local_type_constraint_OpenACCOps9(*this, v.getType(), "operand", index++))) return ::mlir::failure(); } } return ::mlir::success(); } ::llvm::LogicalResult YieldOp::verifyInvariants() { return verifyInvariantsImpl(); } ::mlir::ParseResult YieldOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> operandsOperands; ::llvm::SMLoc operandsOperandsLoc; (void)operandsOperandsLoc; ::llvm::SmallVector<::mlir::Type, 1> operandsTypes; { 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(); } operandsOperandsLoc = parser.getCurrentLocation(); if (parser.parseOperandList(operandsOperands)) return ::mlir::failure(); if (!operandsOperands.empty()) { if (parser.parseColon()) return ::mlir::failure(); if (parser.parseTypeList(operandsTypes)) return ::mlir::failure(); } if (parser.resolveOperands(operandsOperands, operandsTypes, operandsOperandsLoc, result.operands)) return ::mlir::failure(); return ::mlir::success(); } void YieldOp::print(::mlir::OpAsmPrinter &_odsPrinter) { ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); if (!getOperands().empty()) { _odsPrinter << ' '; _odsPrinter << getOperands(); _odsPrinter << ' ' << ":"; _odsPrinter << ' '; _odsPrinter << getOperands().getTypes(); } } void YieldOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { } } // namespace mlir::acc MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::YieldOp) #endif // GET_OP_CLASSES